Expand description
Cryptographic building blocks for Quai applications.
This crate has no wallet storage or transaction wire-format assumptions. Secret keys redact diagnostics and zeroize on drop. Imported input buffers remain the caller’s responsibility. Browser entropy uses Web Crypto and is exercised in the SDK’s actual Chromium worker tests.
Modules§
- curve
- Validated secp256k1 arithmetic for protocol integrations.
Structs§
- Ordered
KeyAggregate - Ordered, untweaked MuSig key aggregation for one process owning every key.
- Public
Key - A validated nonidentity secp256k1 point, represented independently of its encoding.
- Recoverable
Signature - A validated low-S ECDSA signature paired with its full recovery identifier.
- Schnorr
Public Key - A validated BIP340 x-only public key; its implied Y coordinate is even.
- Schnorr
Signature - A parsed 64-byte BIP340 signature. Parsing alone does not verify a message.
- Secret
Bytes - Explicitly exposed fixed-size secret material with redacted diagnostics. The default size is 32 bytes; full shared SEC1 points use 65 bytes.
- Secret
Key - A validated secret scalar, zeroized on drop and redacted in diagnostics.
- Signature
Metadata - Validated parity signature with optional retained legacy EIP-155 metadata. Quai protobuf signatures use explicit chain IDs separately; this wrapper never changes their wire format or infers authorization from a legacy V.
Enums§
- Crypto
Error - Errors never include secret input or backend diagnostic strings.
Constants§
- MAX_
AGGREGATE_ KEYS - Resource policy for one local ordered aggregation, not a consensus input limit.
- MAX_
RANDOM_ BYTES - Maximum entropy request, shared by native and Web Crypto callers.
- MESSAGE_
PREFIX - The actual personal-message prefix in pinned quais.js, despite its Quai name.
Functions§
- fill_
random - Fill caller-owned bytes using the operating system or browser Web Crypto. No fallback PRNG is used. Oversize requests fail before touching the buffer; a backend failure erases the destination so partial entropy cannot be used. Callers own the secrecy and erasure of successfully filled bytes.
- hash_
message - Hash exact message bytes with the pinned quais.js personal-sign prefix.
- hmac_
sha256 - Compute HMAC-SHA256. Treat the returned bytes as secret when used as key material.
- hmac_
sha512 - Compute HMAC-SHA512, used in BIP32 derivation. Derived key bytes are caller-owned secrets.
- keccak256
- Compute Keccak-256, which differs from standardized SHA3-256.
- legacy_
chain_ id - Extract an EIP-155 chain ID from V. Legacy 27/28 returns zero (unspecified); parity-only 0/1 and other values below 35 reject, matching the published helper.
- legacy_
chain_ v - Compute EIP-155 V = 2*chain_id + 35 + parity from normalized 27/28. Invalid normalized V and U256 overflow reject. No active signer policy changes.
- normalized_
v - Normalize parity 0/1, legacy 27/28 or EIP-155 V >= 35 to 27/28. This parses metadata only and does not establish a transaction chain.
- recover_
message_ signer - Recover the address signing exact personal-message bytes. Text callers pass UTF-8 bytes; hex-looking text is not decoded. Recovery does not authenticate an expected signer: compare the returned address with the authorized address.
- ripemd160
- Compute the RIPEMD-160 digest of exact bytes, matching the pinned reference.
- sha256
- Compute SHA-256.
- sha512
- Compute SHA-512.
- verify_
hmac_ sha256 - Verify a full HMAC-SHA256 tag using the backend’s constant-time comparison.
- verify_
hmac_ sha512 - Verify a full HMAC-SHA512 tag using the backend’s constant-time comparison.