|
UltrafastSecp256k1 3.68.0
Ultra high-performance secp256k1 elliptic curve cryptography library
|
Go to the source code of this file.
Classes | |
| struct | ufsecp_gpu_device_info_t |
Macros | |
| #define | UFSECP_NOEXCEPT |
| #define | UFSECP_ERR_GPU_UNAVAILABLE 100 |
| #define | UFSECP_ERR_GPU_DEVICE 101 |
| #define | UFSECP_ERR_GPU_LAUNCH 102 |
| #define | UFSECP_ERR_GPU_MEMORY 103 |
| #define | UFSECP_ERR_GPU_UNSUPPORTED 104 |
| #define | UFSECP_ERR_GPU_BACKEND 105 |
| #define | UFSECP_ERR_GPU_QUEUE 106 |
| #define | UFSECP_GPU_BACKEND_NONE 0 |
| #define | UFSECP_GPU_BACKEND_CUDA 1 |
| #define | UFSECP_GPU_BACKEND_OPENCL 2 |
| #define | UFSECP_GPU_BACKEND_METAL 3 |
| #define | UFSECP_ECDSA_SNARK_WITNESS_BYTES 760 |
| #define | UFSECP_SCHNORR_SNARK_WITNESS_BYTES 472 |
| #define | UFSECP_BIP352_SCAN_PLAN_BYTES 264 |
Typedefs | |
| typedef struct ufsecp_gpu_ctx | ufsecp_gpu_ctx |
Functions | |
| UFSECP_API uint32_t | ufsecp_gpu_backend_count (uint32_t *backend_ids, uint32_t max_ids) UFSECP_NOEXCEPT |
| UFSECP_API const char * | ufsecp_gpu_backend_name (uint32_t backend_id) |
| UFSECP_API int | ufsecp_gpu_is_available (uint32_t backend_id) UFSECP_NOEXCEPT |
| UFSECP_API uint32_t | ufsecp_gpu_device_count (uint32_t backend_id) UFSECP_NOEXCEPT |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_device_info (uint32_t backend_id, uint32_t device_index, ufsecp_gpu_device_info_t *info_out) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_ctx_create (ufsecp_gpu_ctx **ctx_out, uint32_t backend_id, uint32_t device_index) |
| UFSECP_API void | ufsecp_gpu_ctx_destroy (ufsecp_gpu_ctx *ctx) |
| UFSECP_API int | ufsecp_gpu_is_ready (const ufsecp_gpu_ctx *ctx) UFSECP_NOEXCEPT |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_last_error (const ufsecp_gpu_ctx *ctx) |
| UFSECP_API const char * | ufsecp_gpu_last_error_msg (const ufsecp_gpu_ctx *ctx) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_generator_mul_batch (ufsecp_gpu_ctx *ctx, const uint8_t *scalars32, size_t count, uint8_t *out_pubkeys33) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_ecdsa_verify_batch (ufsecp_gpu_ctx *ctx, const uint8_t *msg_hashes32, const uint8_t *pubkeys33, const uint8_t *sigs64, size_t count, uint8_t *out_results) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_schnorr_verify_batch (ufsecp_gpu_ctx *ctx, const uint8_t *msg_hashes32, const uint8_t *pubkeys_x32, const uint8_t *sigs64, size_t count, uint8_t *out_results) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_ecdh_batch (ufsecp_gpu_ctx *ctx, const uint8_t *privkeys32, const uint8_t *peer_pubkeys33, size_t count, uint8_t *out_secrets32) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_hash160_pubkey_batch (ufsecp_gpu_ctx *ctx, const uint8_t *pubkeys33, size_t count, uint8_t *out_hash160) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_msm (ufsecp_gpu_ctx *ctx, const uint8_t *scalars32, const uint8_t *points33, size_t n, uint8_t *out_result33) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_frost_verify_partial_batch (ufsecp_gpu_ctx *ctx, const uint8_t *z_i32, const uint8_t *D_i33, const uint8_t *E_i33, const uint8_t *Y_i33, const uint8_t *rho_i32, const uint8_t *lambda_ie32, const uint8_t *negate_R, const uint8_t *negate_key, size_t count, uint8_t *out_results) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_ecrecover_batch (ufsecp_gpu_ctx *ctx, const uint8_t *msg_hashes32, const uint8_t *sigs64, const int *recids, size_t count, uint8_t *out_pubkeys33, uint8_t *out_valid) |
| UFSECP_API const char * | ufsecp_gpu_error_str (ufsecp_error_t err) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_zk_knowledge_verify_batch (ufsecp_gpu_ctx *ctx, const uint8_t *proofs64, const uint8_t *pubkeys65, const uint8_t *messages32, size_t count, uint8_t *out_results) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_zk_dleq_verify_batch (ufsecp_gpu_ctx *ctx, const uint8_t *proofs64, const uint8_t *G_pts65, const uint8_t *H_pts65, const uint8_t *P_pts65, const uint8_t *Q_pts65, size_t count, uint8_t *out_results) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_bulletproof_verify_batch (ufsecp_gpu_ctx *ctx, const uint8_t *proofs324, const uint8_t *commitments65, const uint8_t *H_generator65, size_t count, uint8_t *out_results) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_bip324_aead_encrypt_batch (ufsecp_gpu_ctx *ctx, const uint8_t *keys32, const uint8_t *nonces12, const uint8_t *plaintexts, const uint32_t *sizes, uint32_t max_payload, size_t count, uint8_t *wire_out) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_bip324_aead_decrypt_batch (ufsecp_gpu_ctx *ctx, const uint8_t *keys32, const uint8_t *nonces12, const uint8_t *wire_in, const uint32_t *sizes, uint32_t max_payload, size_t count, uint8_t *plaintext_out, uint8_t *out_valid) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_zk_ecdsa_snark_witness_batch (ufsecp_gpu_ctx *ctx, const uint8_t *msg_hashes32, const uint8_t *pubkeys33, const uint8_t *sigs64, size_t count, uint8_t *out_witnesses) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_zk_schnorr_snark_witness_batch (ufsecp_gpu_ctx *ctx, const uint8_t *msgs32, const uint8_t *pubkeys_x32, const uint8_t *sigs64, size_t count, uint8_t *out_witnesses) |
| UFSECP_API ufsecp_error_t | ufsecp_bip352_prepare_scan_plan (const uint8_t scan_privkey32[32], uint8_t plan264_out[264]) |
| UFSECP_API ufsecp_error_t | ufsecp_gpu_bip352_scan_batch (ufsecp_gpu_ctx *ctx, const uint8_t scan_privkey32[32], const uint8_t spend_pubkey33[33], const uint8_t *tweak_pubkeys33, size_t n_tweaks, uint64_t *prefix64_out) |
| #define UFSECP_BIP352_SCAN_PLAN_BYTES 264 |
Size in bytes of the precomputed BIP-352 GPU scan key plan. Matches sizeof(BIP352ScanKeyGlv) used by the OpenCL kernel.
Definition at line 535 of file ufsecp_gpu.h.
| #define UFSECP_ECDSA_SNARK_WITNESS_BYTES 760 |
Size in bytes of one flat witness record produced by ufsecp_gpu_zk_ecdsa_snark_witness_batch().
Definition at line 478 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_BACKEND 105 |
Backend driver / runtime error
Definition at line 80 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_DEVICE 101 |
Device not found / init failed
Definition at line 76 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_LAUNCH 102 |
Kernel launch / dispatch failed
Definition at line 77 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_MEMORY 103 |
Device memory alloc/copy failed
Definition at line 78 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_QUEUE 106 |
Command queue / stream error
Definition at line 81 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_UNAVAILABLE 100 |
No GPU backend compiled in
Definition at line 75 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_UNSUPPORTED 104 |
Op not supported on this backend
Definition at line 79 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_CUDA 1 |
Definition at line 88 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_METAL 3 |
Definition at line 90 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_NONE 0 |
Definition at line 87 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_OPENCL 2 |
Definition at line 89 of file ufsecp_gpu.h.
| #define UFSECP_NOEXCEPT |
Definition at line 68 of file ufsecp_gpu.h.
| #define UFSECP_SCHNORR_SNARK_WITNESS_BYTES 472 |
Size in bytes of one flat Schnorr witness record produced by ufsecp_gpu_zk_schnorr_snark_witness_batch().
Definition at line 506 of file ufsecp_gpu.h.
| typedef struct ufsecp_gpu_ctx ufsecp_gpu_ctx |
Definition at line 96 of file ufsecp_gpu.h.
| UFSECP_API ufsecp_error_t ufsecp_bip352_prepare_scan_plan | ( | const uint8_t | scan_privkey32[32], |
| uint8_t | plan264_out[264] | ||
| ) |
Precompute a BIP-352 scan key wNAF plan for repeated GPU batch calls.
This is a CPU-only convenience function. Call it once per scan key and pass the resulting 264-byte plan to ufsecp_gpu_bip352_scan_batch for subsequent scanning. The plan encodes the GLV-decomposed wNAF digits so the GPU does not need to recompute them for each batch.
No GPU context is required; call this before creating the GPU context if needed.
| scan_privkey32 | 32-byte scan private key (big-endian). SECRET. |
| plan264_out | Output buffer of exactly 264 bytes. |
| UFSECP_API uint32_t ufsecp_gpu_backend_count | ( | uint32_t * | backend_ids, |
| uint32_t | max_ids | ||
| ) |
Return number of compiled-in GPU backends (0 if none). Fills backend_ids[] if non-NULL (caller allocates, size >= count).
| UFSECP_API const char * ufsecp_gpu_backend_name | ( | uint32_t | backend_id | ) |
Return short name for a backend id ("CUDA", "OpenCL", "Metal", "none").
| UFSECP_API ufsecp_error_t ufsecp_gpu_bip324_aead_decrypt_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | keys32, | ||
| const uint8_t * | nonces12, | ||
| const uint8_t * | wire_in, | ||
| const uint32_t * | sizes, | ||
| uint32_t | max_payload, | ||
| size_t | count, | ||
| uint8_t * | plaintext_out, | ||
| uint8_t * | out_valid | ||
| ) |
Batch BIP-324 AEAD decrypt on GPU.
Verifies Poly1305 tag and decrypts. Wire input stride: max_payload + 19.
SECRET-BEARING operation. Keys are uploaded to device memory.
| ctx | GPU context. |
| keys32 | Input: count * 32 bytes. |
| nonces12 | Input: count * 12 bytes. |
| wire_in | Input: count * (max_payload + 19) bytes. |
| sizes | Input: count uint32_t (payload sizes). |
| max_payload | Maximum payload size. |
| count | Number of packets. |
| plaintext_out | Output: count * max_payload bytes. |
| out_valid | Output: count bytes (1 = ok, 0 = tag mismatch). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_bip324_aead_encrypt_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | keys32, | ||
| const uint8_t * | nonces12, | ||
| const uint8_t * | plaintexts, | ||
| const uint32_t * | sizes, | ||
| uint32_t | max_payload, | ||
| size_t | count, | ||
| uint8_t * | wire_out | ||
| ) |
Batch BIP-324 AEAD encrypt on GPU.
Each thread processes one independent packet with its own key, nonce, and payload. Wire format per packet: [3B length header] [ciphertext] [16B tag]. Output stride per packet: max_payload + 19 bytes.
SECRET-BEARING operation. Keys are uploaded to device memory.
| ctx | GPU context. |
| keys32 | Input: count * 32 bytes (ChaCha20-Poly1305 keys). |
| nonces12 | Input: count * 12 bytes. |
| plaintexts | Input: count * max_payload bytes (contiguous). |
| sizes | Input: count uint32_t (actual payload size per packet). |
| max_payload | Maximum payload size (all payloads padded to this). |
| count | Number of packets. |
| wire_out | Output: count * (max_payload + 19) bytes. |
| UFSECP_API ufsecp_error_t ufsecp_gpu_bip352_scan_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t | scan_privkey32[32], | ||
| const uint8_t | spend_pubkey33[33], | ||
| const uint8_t * | tweak_pubkeys33, | ||
| size_t | n_tweaks, | ||
| uint64_t * | prefix64_out | ||
| ) |
GPU batch BIP-352 Silent Payment scanning.
For each sender tweak public key in the block, computes the full BIP-352 scanning pipeline and outputs the upper 64 bits of the secp256k1 x-coordinate of the candidate output point.
Pipeline per tweak key:
The caller compares prefix64_out[i] against the upper 64 bits of every known output's x-coordinate in the block to detect matching Silent Payment outputs.
SECRET-BEARING: scan_privkey32 is uploaded to device memory during this call. Callers should zeroize it immediately after the call if required.
| ctx | GPU context (OpenCL or CUDA; Metal returns UFSECP_ERR_GPU_UNSUPPORTED). |
| scan_privkey32 | 32-byte scan private key (big-endian). SECRET. |
| spend_pubkey33 | 33-byte compressed secp256k1 spend public key. |
| tweak_pubkeys33 | Input: n_tweaks × 33 bytes, compressed pubkeys. |
| n_tweaks | Number of tweak keys to process. |
| prefix64_out | Output: n_tweaks × uint64_t, one per tweak key. |
| UFSECP_API ufsecp_error_t ufsecp_gpu_bulletproof_verify_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | proofs324, | ||
| const uint8_t * | commitments65, | ||
| const uint8_t * | H_generator65, | ||
| size_t | count, | ||
| uint8_t * | out_results | ||
| ) |
Batch Bulletproof polynomial-check verification on GPU.
Verifies the polynomial commitment portion of a Bulletproof range proof. Each proof is 324 bytes: A[65] || S[65] || T1[65] || T2[65] || tau_x[32] || t_hat[32]. Points use 65-byte uncompressed format (04 prefix).
PUBLIC-DATA operation.
| ctx | GPU context. |
| proofs324 | Input: count * 324 bytes. |
| commitments65 | Input: count * 65 bytes (Pedersen commitments). |
| H_generator65 | Input: 65 bytes (Pedersen generator H). |
| count | Number of proofs. |
| out_results | Output: count bytes (1 = valid, 0 = invalid). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_ctx_create | ( | ufsecp_gpu_ctx ** | ctx_out, |
| uint32_t | backend_id, | ||
| uint32_t | device_index | ||
| ) |
Create a GPU context for the given backend and device.
| ctx_out | Receives the opaque context pointer. |
| backend_id | UFSECP_GPU_BACKEND_CUDA / OPENCL / METAL. |
| device_index | Device index within the backend (0 = default). |
| UFSECP_API void ufsecp_gpu_ctx_destroy | ( | ufsecp_gpu_ctx * | ctx | ) |
Destroy a GPU context and release all device resources.
| UFSECP_API uint32_t ufsecp_gpu_device_count | ( | uint32_t | backend_id | ) |
Return number of devices for the given backend (0 if unavailable).
| UFSECP_API ufsecp_error_t ufsecp_gpu_device_info | ( | uint32_t | backend_id, |
| uint32_t | device_index, | ||
| ufsecp_gpu_device_info_t * | info_out | ||
| ) |
Fill device info for (backend_id, device_index).
| UFSECP_API ufsecp_error_t ufsecp_gpu_ecdh_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | privkeys32, | ||
| const uint8_t * | peer_pubkeys33, | ||
| size_t | count, | ||
| uint8_t * | out_secrets32 | ||
| ) |
Batch ECDH shared secret computation.
SECRET-BEARING operation. Private keys are uploaded to device memory. Use only when the threat model permits GPU-side secret handling.
| ctx | GPU context. |
| privkeys32 | Input: count * 32 bytes (private keys, big-endian). |
| peer_pubkeys33 | Input: count * 33 bytes (compressed peer pubkeys). |
| count | Number of items. |
| out_secrets32 | Output: count * 32 bytes (shared secrets = SHA-256(x)). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_ecdsa_verify_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | msg_hashes32, | ||
| const uint8_t * | pubkeys33, | ||
| const uint8_t * | sigs64, | ||
| size_t | count, | ||
| uint8_t * | out_results | ||
| ) |
Batch ECDSA verification.
PUBLIC-DATA operation.
| ctx | GPU context. |
| msg_hashes32 | Input: count * 32 bytes (message hashes, big-endian). |
| pubkeys33 | Input: count * 33 bytes (compressed pubkeys). |
| sigs64 | Input: count * 64 bytes (compact R||S signatures). |
| count | Number of items. |
| out_results | Output: count bytes (1 = valid, 0 = invalid per item). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_ecrecover_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | msg_hashes32, | ||
| const uint8_t * | sigs64, | ||
| const int * | recids, | ||
| size_t | count, | ||
| uint8_t * | out_pubkeys33, | ||
| uint8_t * | out_valid | ||
| ) |
Batch ECDSA public-key recovery on GPU. For each item recovers the compressed public key from (msg_hash, sig, recid). An entry that fails recovery writes 33 zero bytes into out_pubkeys33 and out_valid[i] = 0.
| ctx | GPU context. |
| msg_hashes32 | Input: count * 32 bytes (32-byte message hashes). |
| sigs64 | Input: count * 64 bytes (compact R[32]||S[32], big-endian). |
| recids | Input: count ints (recovery id 0-3 per entry). |
| count | Number of entries. |
| out_pubkeys33 | Output: count * 33 bytes (compressed pubkeys; zeros on failure). |
| out_valid | Output: count bytes (1 = recovered, 0 = failed). |
| UFSECP_API const char * ufsecp_gpu_error_str | ( | ufsecp_error_t | err | ) |
Map GPU-specific error code to description (passes through to ufsecp_error_str for CPU error codes).
| UFSECP_API ufsecp_error_t ufsecp_gpu_frost_verify_partial_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | z_i32, | ||
| const uint8_t * | D_i33, | ||
| const uint8_t * | E_i33, | ||
| const uint8_t * | Y_i33, | ||
| const uint8_t * | rho_i32, | ||
| const uint8_t * | lambda_ie32, | ||
| const uint8_t * | negate_R, | ||
| const uint8_t * | negate_key, | ||
| size_t | count, | ||
| uint8_t * | out_results | ||
| ) |
Batch FROST partial signature verification.
Each entry verifies: R_i = D_i + rho_i*E_i, lhs = z_i*G, rhs = R_i + lambda_ie*Y_i result[i] = (lhs == rhs). Returns UFSECP_ERR_UNSUPPORTED when backend does not implement FROST.
| ctx | GPU context. |
| z_i32 | Input: count * 32 bytes (partial sig scalars, big-endian). |
| D_i33 | Input: count * 33 bytes (hiding nonce commitments, compressed). |
| E_i33 | Input: count * 33 bytes (binding nonce commitments, compressed). |
| Y_i33 | Input: count * 33 bytes (verification share pubkeys, compressed). |
| rho_i32 | Input: count * 32 bytes (per-signer binding factors, big-endian). |
| lambda_ie32 | Input: count * 32 bytes (lambda_i * e products, big-endian). |
| negate_R | Input: count bytes (1 = negate R_i, 0 = keep). |
| negate_key | Input: count bytes (1 = negate Y_i, 0 = keep). |
| count | Number of partial signatures to verify. |
| out_results | Output: count bytes (1 = valid, 0 = invalid per entry). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_generator_mul_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | scalars32, | ||
| size_t | count, | ||
| uint8_t * | out_pubkeys33 | ||
| ) |
Batch generator multiplication: compute k[i] * G for each scalar.
PUBLIC-DATA operation. Scalars are treated as public values.
| ctx | GPU context. |
| scalars32 | Input: count * 32 bytes (big-endian scalars, contiguous). |
| count | Number of scalars. |
| out_pubkeys33 | Output: count * 33 bytes (compressed pubkeys, contiguous). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_hash160_pubkey_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | pubkeys33, | ||
| size_t | count, | ||
| uint8_t * | out_hash160 | ||
| ) |
Batch Hash160 of compressed public keys: RIPEMD-160(SHA-256(pubkey33)).
PUBLIC-DATA operation.
| ctx | GPU context. |
| pubkeys33 | Input: count * 33 bytes (compressed pubkeys). |
| count | Number of items. |
| out_hash160 | Output: count * 20 bytes (hash160 digests). |
| UFSECP_API int ufsecp_gpu_is_available | ( | uint32_t | backend_id | ) |
Return 1 if the backend is compiled in AND at least one device exists.
| UFSECP_API int ufsecp_gpu_is_ready | ( | const ufsecp_gpu_ctx * | ctx | ) |
Return 1 if the GPU context is fully initialized and ready to accept batch operations, 0 otherwise. A context is ready after a successful ufsecp_gpu_ctx_create() and until ufsecp_gpu_ctx_destroy() is called. Returns 0 if ctx is NULL.
| UFSECP_API ufsecp_error_t ufsecp_gpu_last_error | ( | const ufsecp_gpu_ctx * | ctx | ) |
Return the last error code from this GPU context.
| UFSECP_API const char * ufsecp_gpu_last_error_msg | ( | const ufsecp_gpu_ctx * | ctx | ) |
Return the last error message from this GPU context (never NULL). The returned pointer is borrowed storage owned by ctx/backend state. It remains valid until the next call that mutates the same ctx, or until ufsecp_gpu_ctx_destroy(ctx). Copy it if it must outlive the context/call.
| UFSECP_API ufsecp_error_t ufsecp_gpu_msm | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | scalars32, | ||
| const uint8_t * | points33, | ||
| size_t | n, | ||
| uint8_t * | out_result33 | ||
| ) |
Multi-scalar multiplication: compute sum(scalars[i] * points[i]).
PUBLIC-DATA operation.
| ctx | GPU context. |
| scalars32 | Input: n * 32 bytes (big-endian scalars). |
| points33 | Input: n * 33 bytes (compressed points). |
| n | Number of (scalar, point) pairs. |
| out_result33 | Output: 33 bytes (compressed result point). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_schnorr_verify_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | msg_hashes32, | ||
| const uint8_t * | pubkeys_x32, | ||
| const uint8_t * | sigs64, | ||
| size_t | count, | ||
| uint8_t * | out_results | ||
| ) |
Batch BIP-340 Schnorr verification.
PUBLIC-DATA operation.
| ctx | GPU context. |
| msg_hashes32 | Input: count * 32 bytes (message hashes). |
| pubkeys_x32 | Input: count * 32 bytes (x-only public keys). |
| sigs64 | Input: count * 64 bytes (r||s Schnorr signatures). |
| count | Number of items. |
| out_results | Output: count bytes (1 = valid, 0 = invalid per item). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_zk_dleq_verify_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | proofs64, | ||
| const uint8_t * | G_pts65, | ||
| const uint8_t * | H_pts65, | ||
| const uint8_t * | P_pts65, | ||
| const uint8_t * | Q_pts65, | ||
| size_t | count, | ||
| uint8_t * | out_results | ||
| ) |
Batch DLEQ proof verification on GPU.
Verifies log_G(P) == log_H(Q) via Chaum–Pedersen protocol. Each proof is 64 bytes: e[32] || s[32] (big-endian). Each point is 65 bytes: 04 || x[32] || y[32] (uncompressed affine).
PUBLIC-DATA operation.
| ctx | GPU context. |
| proofs64 | Input: count * 64 bytes. |
| G_pts65 | Input: count * 65 bytes (base point G per proof). |
| H_pts65 | Input: count * 65 bytes (base point H per proof). |
| P_pts65 | Input: count * 65 bytes (public key P per proof). |
| Q_pts65 | Input: count * 65 bytes (public key Q per proof). |
| count | Number of proofs. |
| out_results | Output: count bytes (1 = valid, 0 = invalid). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_zk_ecdsa_snark_witness_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | msg_hashes32, | ||
| const uint8_t * | pubkeys33, | ||
| const uint8_t * | sigs64, | ||
| size_t | count, | ||
| uint8_t * | out_witnesses | ||
| ) |
Compute ECDSA SNARK witnesses for a batch of (message, pubkey, sig) tuples.
| ctx | GPU context returned by ufsecp_gpu_ctx_create(). |
| msg_hashes32 | Input: count × 32 bytes (one BE SHA-256 hash per item). |
| pubkeys33 | Input: count × 33 bytes (compressed SEC1 public keys). |
| sigs64 | Input: count × 64 bytes (BE compact r|s signatures). |
| count | Number of items to process. |
| out_witnesses | Output: count × UFSECP_ECDSA_SNARK_WITNESS_BYTES bytes. Each 760-byte record contains input values, intermediate witness scalars, and 5×52-bit foreign-field limbs. |
| UFSECP_API ufsecp_error_t ufsecp_gpu_zk_knowledge_verify_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | proofs64, | ||
| const uint8_t * | pubkeys65, | ||
| const uint8_t * | messages32, | ||
| size_t | count, | ||
| uint8_t * | out_results | ||
| ) |
Batch Schnorr knowledge-proof verification on GPU.
Verifies s*G == R + e*P where e = H("ZK/knowledge" || rx || P || G || msg). Each proof is 64 bytes: rx[32] || s[32] (big-endian). Each pubkey is 65 bytes: 04 || x[32] || y[32] (uncompressed affine).
PUBLIC-DATA operation.
| ctx | GPU context. |
| proofs64 | Input: count * 64 bytes. |
| pubkeys65 | Input: count * 65 bytes (04 prefix). |
| messages32 | Input: count * 32 bytes. |
| count | Number of proofs. |
| out_results | Output: count bytes (1 = valid, 0 = invalid). |
| UFSECP_API ufsecp_error_t ufsecp_gpu_zk_schnorr_snark_witness_batch | ( | ufsecp_gpu_ctx * | ctx, |
| const uint8_t * | msgs32, | ||
| const uint8_t * | pubkeys_x32, | ||
| const uint8_t * | sigs64, | ||
| size_t | count, | ||
| uint8_t * | out_witnesses | ||
| ) |
Compute BIP-340 Schnorr SNARK witnesses for a batch of (message, xonly-pubkey, sig) tuples.
| ctx | GPU context returned by ufsecp_gpu_ctx_create(). |
| msgs32 | Input: count × 32 bytes (messages, per BIP-340). |
| pubkeys_x32 | Input: count × 32 bytes (x-only public keys). |
| sigs64 | Input: count × 64 bytes (BIP-340 sigs: R.x[32] || s[32]). |
| count | Number of items to process. |
| out_witnesses | Output: count × UFSECP_SCHNORR_SNARK_WITNESS_BYTES bytes. Each record contains public inputs, lifted point witnesses, challenge scalar, and 5×52-bit foreign-field limbs. |