atproto_repo/key
atproto signing keys: P-256 and secp256k1, in the compressed form that
did:key and DID document Multikey entries carry, and the atproto
signature rule (64-byte compact r || s, low-S only).
Types
pub type KeyError {
NotDidKey
UnsupportedVerificationMethod(String)
UnsupportedMultibase(prefix: String)
InvalidBase58
MalformedMulticodec
UnsupportedKeyType(multicodec: Int)
UnsupportedCurve
BadKeyLength(Int)
NotCompressedPoint
InvalidPoint
}
Constructors
-
NotDidKey -
UnsupportedVerificationMethod(String) -
UnsupportedMultibase(prefix: String) -
InvalidBase58 -
MalformedMulticodec -
UnsupportedKeyType(multicodec: Int) -
UnsupportedCurve -
BadKeyLength(Int) -
NotCompressedPoint -
InvalidPoint
PublicKey
opaquepub opaque type PublicKey
pub type SignatureError {
BadSignatureLength(Int)
HighS
Mismatch
}
Constructors
-
BadSignatureLength(Int) -
HighS -
Mismatch
Values
pub fn from_ec(key: ec.PublicKey) -> Result(PublicKey, KeyError)
Wraps a kryptos key. Only P-256 and secp256k1 are atproto signing curves.
pub fn from_multikey(
multibase: String,
) -> Result(PublicKey, KeyError)
Parses a multibase base58btc string holding a multicodec-prefixed
compressed point: the publicKeyMultibase of a Multikey verification
method, and the body of a did:key.
pub fn from_verification_method(
method_type: String,
public_key_multibase: String,
) -> Result(PublicKey, KeyError)
Builds a key from a DID document verification method. Multikey carries a
multicodec prefix; the two 2019 suites carry the bare compressed point and
name the curve in the type, so the curve can never be missing.
pub fn verify(
key: PublicKey,
message: BitArray,
signature: BitArray,
) -> Result(Nil, SignatureError)
Verifies signature over the SHA-256 of message. High-S signatures are
rejected even when they are mathematically valid, because atproto
requires the canonical low-S form.