Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToPrivKey(keyBytes []byte, kt KeyType) (crypto.PrivateKey, error)
- func BytesToPubKey(keyBytes []byte, kt KeyType) (crypto.PublicKey, error)
- func GenerateBBSKeyPair() (*bbsg2.PublicKey, *bbsg2.PrivateKey, error)
- func GenerateDilithiumKeyPair(m dilithium.Mode) (dilithium.PublicKey, dilithium.PrivateKey, error)
- func GenerateEd25519Key() (ed25519.PublicKey, ed25519.PrivateKey, error)
- func GenerateKeyByKeyType(kt KeyType) (crypto.PublicKey, crypto.PrivateKey, error)
- func GenerateP224Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateP256Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateP384Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateP521Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
- func GenerateRSA2048Key() (rsa.PublicKey, rsa.PrivateKey, error)
- func GenerateSECP256k1Key() (secp.PublicKey, secp.PrivateKey, error)
- func GenerateX25519Key() (x25519.PublicKey, x25519.PrivateKey, error)
- func GetModeFromDilithiumPrivateKey(privKey dilithium.PrivateKey) (dilithium.Mode, error)
- func GetModeFromDilithiumPublicKey(pubKey dilithium.PublicKey) (dilithium.Mode, error)
- func IsSupportedKeyType(kt KeyType) bool
- func IsSupportedSignatureAlg(sa SignatureAlgorithm) bool
- func PrivKeyToBytes(key crypto.PrivateKey) ([]byte, error)
- func PubKeyToBytes(key crypto.PublicKey, opts ...Option) ([]byte, error)
- func SignBBSMessage(privKey *bbsg2.PrivateKey, messages ...[]byte) ([]byte, error)
- func VerifyBBSMessage(pubKey *bbsg2.PublicKey, signature, message []byte) error
- func VerifyDerivedBBSMessage(pubKey *bbsg2.PublicKey, signature, message, nonce []byte) error
- type BBSPlusSigner
- type BBSPlusVerifier
- func (v *BBSPlusVerifier) DeriveProof(messages [][]byte, sigBytes, nonce []byte, revealedIndexes []int) ([]byte, error)
- func (v *BBSPlusVerifier) GetKeyID() string
- func (v *BBSPlusVerifier) Verify(message, signature []byte) error
- func (v *BBSPlusVerifier) VerifyDerived(message, signature, nonce []byte) error
- func (v *BBSPlusVerifier) VerifyMultiple(signature []byte, messages ...[]byte) error
- type HashType
- type KeyType
- type Option
- type Proof
- type SignatureAlgorithm
Constants ¶
const ( Ed25519 KeyType = "Ed25519" X25519 KeyType = "X25519" SECP256k1 KeyType = "secp256k1" SECP256k1ECDSA KeyType = "secp256k1-ECDSA" P224 KeyType = "P-224" P256 KeyType = "P-256" P384 KeyType = "P-384" P521 KeyType = "P-521" RSA KeyType = "RSA" BLS12381G1 KeyType = "BLS12381G1" BLS12381G2 KeyType = "BLS12381G2" Dilithium2 KeyType = "Dilithium2" Dilithium3 KeyType = "Dilithium3" Dilithium5 KeyType = "Dilithium5" RSAKeySize int = 2048 )
Variables ¶
var (
ECDSAMarshalCompressed = Option{Name: "ecdsa-compressed", Value: true}
)
Functions ¶
func BytesToPrivKey ¶
func BytesToPrivKey(keyBytes []byte, kt KeyType) (crypto.PrivateKey, error)
BytesToPrivKey reconstructs a private key given some bytes and a target key type It is assumed the key was turned into byte form using the sibling method `PrivKeyToBytes`
func BytesToPubKey ¶
BytesToPubKey reconstructs a public key given some bytes and a target key type It is assumed the key was turned into byte form using the sibling method `PubKeyToBytes`
func GenerateBBSKeyPair ¶
func GenerateBBSKeyPair() (*bbsg2.PublicKey, *bbsg2.PrivateKey, error)
GenerateBBSKeyPair https://w3c-ccg.github.io/ldp-bbs2020
func GenerateDilithiumKeyPair ¶
GenerateDilithiumKeyPair generates a new Dilithium key pair for the given mode
func GenerateEd25519Key ¶
func GenerateEd25519Key() (ed25519.PublicKey, ed25519.PrivateKey, error)
func GenerateKeyByKeyType ¶
GenerateKeyByKeyType creates a brand-new key, returning the public and private key for the given key type
func GenerateP224Key ¶
func GenerateP224Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateP256Key ¶
func GenerateP256Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateP384Key ¶
func GenerateP384Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateP521Key ¶
func GenerateP521Key() (ecdsa.PublicKey, ecdsa.PrivateKey, error)
func GenerateRSA2048Key ¶
func GenerateRSA2048Key() (rsa.PublicKey, rsa.PrivateKey, error)
func GenerateSECP256k1Key ¶
func GenerateSECP256k1Key() (secp.PublicKey, secp.PrivateKey, error)
func GenerateX25519Key ¶
func GenerateX25519Key() (x25519.PublicKey, x25519.PrivateKey, error)
func GetModeFromDilithiumPrivateKey ¶
func GetModeFromDilithiumPrivateKey(privKey dilithium.PrivateKey) (dilithium.Mode, error)
GetModeFromDilithiumPrivateKey returns the DilithiumMode from a dilithium.PrivateKey, validating the key is a valid private key
func GetModeFromDilithiumPublicKey ¶
GetModeFromDilithiumPublicKey returns the DilithiumMode from a dilithium.PublicKey, validating the key is a valid public key
func IsSupportedKeyType ¶
IsSupportedKeyType returns true if the key type is supported
func IsSupportedSignatureAlg ¶
func IsSupportedSignatureAlg(sa SignatureAlgorithm) bool
IsSupportedSignatureAlg returns true if the signature algorithm is supported
func PrivKeyToBytes ¶
func PrivKeyToBytes(key crypto.PrivateKey) ([]byte, error)
PrivKeyToBytes constructs a byte representation of a private key, for a set number of supported key types
func PubKeyToBytes ¶
PubKeyToBytes constructs a byte representation of a public key, for a set number of supported key types
func SignBBSMessage ¶
func SignBBSMessage(privKey *bbsg2.PrivateKey, messages ...[]byte) ([]byte, error)
func VerifyBBSMessage ¶
Types ¶
type BBSPlusSigner ¶
type BBSPlusSigner struct { *bbsg2.PrivateKey *bbsg2.PublicKey *BBSPlusVerifier // contains filtered or unexported fields }
func NewBBSPlusSigner ¶
func NewBBSPlusSigner(kid string, privKey *bbsg2.PrivateKey) *BBSPlusSigner
func (*BBSPlusSigner) GetKeyID ¶
func (s *BBSPlusSigner) GetKeyID() string
func (*BBSPlusSigner) GetVerifier ¶
func (s *BBSPlusSigner) GetVerifier() *BBSPlusVerifier
func (*BBSPlusSigner) SignMultiple ¶
func (s *BBSPlusSigner) SignMultiple(messages ...[]byte) ([]byte, error)
type BBSPlusVerifier ¶
func NewBBSPlusVerifier ¶
func NewBBSPlusVerifier(kid string, pubKey *bbsg2.PublicKey) *BBSPlusVerifier
func (*BBSPlusVerifier) DeriveProof ¶
func (*BBSPlusVerifier) GetKeyID ¶
func (v *BBSPlusVerifier) GetKeyID() string
func (*BBSPlusVerifier) Verify ¶
func (v *BBSPlusVerifier) Verify(message, signature []byte) error
func (*BBSPlusVerifier) VerifyDerived ¶
func (v *BBSPlusVerifier) VerifyDerived(message, signature, nonce []byte) error
VerifyDerived verifies a derived proof, or a selective disclosure proof that has been derived from a BBSPlusSignature signed object.
func (*BBSPlusVerifier) VerifyMultiple ¶
func (v *BBSPlusVerifier) VerifyMultiple(signature []byte, messages ...[]byte) error
type KeyType ¶
type KeyType string
func GetExperimentalKeyTypes ¶
func GetExperimentalKeyTypes() []KeyType
GetExperimentalKeyTypes returns a list of experimental key types
func GetKeyTypeFromPrivateKey ¶
func GetKeyTypeFromPrivateKey(key crypto.PrivateKey) (KeyType, error)
GetKeyTypeFromPrivateKey returns the key type for a private key for known key types
func GetSupportedKeyTypes ¶
func GetSupportedKeyTypes() []KeyType
GetSupportedKeyTypes returns a list of supported key types
type SignatureAlgorithm ¶
type SignatureAlgorithm string
const ( // EdDSA uses an ed25519 key EdDSA SignatureAlgorithm = "EdDSA" // ES256K uses a secp256k1 key ES256K SignatureAlgorithm = "ES256K" // ES256 uses a p-256 curve key ES256 SignatureAlgorithm = "ES256" // ES384 uses a p-384 curve key ES384 SignatureAlgorithm = "ES384" // PS256 uses a 2048-bit RSA key PS256 SignatureAlgorithm = "PS256" Dilithium2Sig SignatureAlgorithm = "Dilithium2" Dilithium3Sig SignatureAlgorithm = "Dilithium3" Dilithium5Sig SignatureAlgorithm = "Dilithium5" )
func GetExperimentalSignatureAlgs ¶
func GetExperimentalSignatureAlgs() []SignatureAlgorithm
GetExperimentalSignatureAlgs returns a list of experimental signature algorithms
func GetSupportedSignatureAlgs ¶
func GetSupportedSignatureAlgs() []SignatureAlgorithm
GetSupportedSignatureAlgs returns a list of supported signature algorithms