|
UltrafastSecp256k1 3.50.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_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 |
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_API const char * | ufsecp_gpu_backend_name (uint32_t backend_id) |
| UFSECP_API int | ufsecp_gpu_is_available (uint32_t backend_id) |
| UFSECP_API uint32_t | ufsecp_gpu_device_count (uint32_t backend_id) |
| 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 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) |
| #define UFSECP_ERR_GPU_BACKEND 105 |
Backend driver / runtime error
Definition at line 77 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_DEVICE 101 |
Device not found / init failed
Definition at line 73 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_LAUNCH 102 |
Kernel launch / dispatch failed
Definition at line 74 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_MEMORY 103 |
Device memory alloc/copy failed
Definition at line 75 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_QUEUE 106 |
Command queue / stream error
Definition at line 78 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_UNAVAILABLE 100 |
No GPU backend compiled in
Definition at line 72 of file ufsecp_gpu.h.
| #define UFSECP_ERR_GPU_UNSUPPORTED 104 |
Op not supported on this backend
Definition at line 76 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_CUDA 1 |
Definition at line 85 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_METAL 3 |
Definition at line 87 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_NONE 0 |
Definition at line 84 of file ufsecp_gpu.h.
| #define UFSECP_GPU_BACKEND_OPENCL 2 |
Definition at line 86 of file ufsecp_gpu.h.
| typedef struct ufsecp_gpu_ctx ufsecp_gpu_ctx |
Definition at line 93 of file ufsecp_gpu.h.
| 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).
Definition at line 104 of file ufsecp_gpu_impl.cpp.
| UFSECP_API const char * ufsecp_gpu_backend_name | ( | uint32_t | backend_id | ) |
Return short name for a backend id ("CUDA", "OpenCL", "Metal", "none").
Definition at line 114 of file ufsecp_gpu_impl.cpp.
| 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). |
Definition at line 494 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_bip324_sizes(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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. |
Definition at line 469 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_bip324_sizes(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 440 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_bulletproof_prefixes(), has_valid_uncompressed_pubkeys(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_BAD_PUBKEY, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 164 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, to_abi_error(), UFSECP_ERR_GPU_UNAVAILABLE, UFSECP_ERR_INTERNAL, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| UFSECP_API void ufsecp_gpu_ctx_destroy | ( | ufsecp_gpu_ctx * | ctx | ) |
Destroy a GPU context and release all device resources.
Definition at line 189 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend.
| UFSECP_API uint32_t ufsecp_gpu_device_count | ( | uint32_t | backend_id | ) |
Return number of devices for the given backend (0 if unavailable).
Definition at line 128 of file ufsecp_gpu_impl.cpp.
| 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).
Definition at line 136 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_device_info_t::backend_id, ufsecp_gpu_device_info_t::compute_units, ufsecp_gpu_device_info_t::device_index, ufsecp_gpu_device_info_t::global_mem_bytes, ufsecp_gpu_device_info_t::max_clock_mhz, ufsecp_gpu_device_info_t::max_threads_per_block, ufsecp_gpu_device_info_t::name, to_abi_error(), UFSECP_ERR_GPU_UNAVAILABLE, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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)). |
Definition at line 268 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_compressed_pubkeys(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_BAD_PUBKEY, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 226 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 360 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_recovery_ids(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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).
Definition at line 525 of file ufsecp_gpu_impl.cpp.
References UFSECP_ERR_ARITH, UFSECP_ERR_BAD_INPUT, UFSECP_ERR_BAD_KEY, UFSECP_ERR_BAD_PUBKEY, UFSECP_ERR_BAD_SIG, UFSECP_ERR_BUF_TOO_SMALL, UFSECP_ERR_GPU_BACKEND, UFSECP_ERR_GPU_DEVICE, UFSECP_ERR_GPU_LAUNCH, UFSECP_ERR_GPU_MEMORY, UFSECP_ERR_GPU_QUEUE, UFSECP_ERR_GPU_UNAVAILABLE, UFSECP_ERR_GPU_UNSUPPORTED, UFSECP_ERR_INTERNAL, UFSECP_ERR_NULL_ARG, UFSECP_ERR_SELFTEST, UFSECP_ERR_VERIFY_FAIL, and UFSECP_OK.
| 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). |
Definition at line 327 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_compressed_pubkeys(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_BAD_PUBKEY, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 210 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 291 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_compressed_pubkeys(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_BAD_PUBKEY, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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.
Definition at line 123 of file ufsecp_gpu_impl.cpp.
| UFSECP_API ufsecp_error_t ufsecp_gpu_last_error | ( | const ufsecp_gpu_ctx * | ctx | ) |
Return the last error code from this GPU context.
Definition at line 196 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, to_abi_error(), and UFSECP_ERR_NULL_ARG.
| 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.
Definition at line 201 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend.
| 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). |
Definition at line 310 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 247 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 412 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_uncompressed_pubkeys(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_BAD_PUBKEY, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.
| 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). |
Definition at line 389 of file ufsecp_gpu_impl.cpp.
References ufsecp_gpu_ctx::backend, has_valid_uncompressed_pubkeys(), kMaxGpuBatchN, to_abi_error(), UFSECP_ERR_BAD_INPUT, UFSECP_ERR_BAD_PUBKEY, UFSECP_ERR_NULL_ARG, UFSECP_GPU_CATCH, and UFSECP_OK.