crypto library
Cryptographic building blocks of affinidi_tsp, exported for key-type
extensions (such as affinidi_tsp_pq) and for test-vector verification.
Application code should not need this library: use affinidi_tsp.dart.
Classes
- CallbackSigningKey
-
A signing key backed by a callback, for custody that never exposes the key
(a wallet,
ssi'sDidSigner, a KMS). - ChaCha20Poly1305
-
ChaCha20-Poly1305 (RFC 8439) single-shot AEAD over
package:cryptography. - DhkemX25519
- DHKEM(X25519, HKDF-SHA256), RFC 9180 §4.1 and §7.1.
- Ed25519SigningKey
- An Ed25519 signing key held in memory as its 32-byte seed.
- Ed25519VerificationKey
- An Ed25519 public verification key.
- HkdfSha256
-
HKDF-SHA256 (RFC 5869), built on the
cryptopackage's HMAC. - Hpke
-
RFC 9180 HPKE in Base mode with HKDF-SHA256 (
0x0001) and ChaCha20Poly1305 (0x0003), over any KEM supplied through TspEncryptionKey / TspDecryptionKey. - HpkeKeySchedule
- The HPKE key schedule output for one context.
- HpkeSealed
- The result of a single-shot HPKE seal.
- KemEncapsulation
- The result of a KEM encapsulation.
- SealedBox
-
libsodium
crypto_box_seal/crypto_box_seal_open(TSP Rev 3 §8.3). - TspDecryptionKey
- A private decryption key bound to a VID.
- TspDigest
- A 32-byte TSP digest together with its hash function.
- TspEncryptionKey
- A public encryption key bound to a VID.
- TspKem
- An HPKE KEM TSP can select through a VID's encryption key type.
- TspSigningKey
- A private signing key bound to a VID.
- TspVerificationKey
- A public verification key bound to a VID.
- X25519
- X25519 (RFC 7748) on TweetNaCl's constant-time scalar multiplication.
- X25519DecryptionKey
- An X25519 private key, held in memory or behind a key-agreement callback.
- X25519EncryptionKey
- An X25519 public encryption key (DHKEM(X25519, HKDF-SHA256)).
- X25519KeyAgreement
- Raw X25519 key agreement, needed by the libsodium sealed box.
Enums
- TspDigestAlgorithm
- Hash function of a TSP digest, identified on the wire by its CESR code.
- TspErrorCode
- Machine-readable classification of a TspException.
- TspSignatureAlgorithm
- A signature algorithm a VID's signing key may use.
Functions
-
computeBlake2b(
List< int> data, int length) → Uint8List -
Unkeyed Blake2b of
datawith alength-byte output. -
computeSha256(
List< int> data) → Uint8List -
SHA2-256 of
data. -
secureRandomBytes(
int length) → Uint8List -
Returns
lengthbytes from the platform's cryptographically secure RNG.
Exceptions / Errors
- TspDecryptionException
- Decryption or AEAD authentication failed.
- TspDigestException
- A self-addressing TSP digest did not verify.
- TspException
- Base class of every exception this library throws.
- TspInvalidInputException
- The caller supplied invalid input (a local programming error, not an untrusted-input failure).
- TspMalformedException
- CESR framing could not be parsed, or broke a structural rule.
- TspReceiverException
- The message is not addressed to the receiving identity.
- TspRelationshipException
- The relationship state forbids the message or operation.
- TspSenderException
- The envelope or ESSR sender does not match the expected sender.
- TspSignatureException
- The TSP signature did not verify.
- TspUnsupportedException
- The operation, scheme, payload type or option is not supported.
- TspVersionException
- The message carries an unknown or unsupported TSP version.