Documentation
¶
Index ¶
- Constants
- Variables
- func BuildIMContentDigest(payload []byte) string
- func BuildIMSignatureInput(keyID string, options IMGenerationOptions) (string, error)
- func DecodeIMSignature(signature string) (string, []byte, error)
- func EncodeIMSignature(signatureBytes []byte, label string) string
- func GenerateGroupReceiptProof(receipt map[string]any, privateKey anp.PrivateKeyMaterial, ...) (map[string]any, error)
- func GenerateW3CProof(document map[string]any, privateKey anp.PrivateKeyMaterial, ...) (map[string]any, error)
- func VerifyGroupReceiptProof(receipt map[string]any, publicKey anp.PublicKeyMaterial) error
- func VerifyIMContentDigest(payload []byte, contentDigest string) bool
- func VerifyW3CProof(document map[string]any, publicKey anp.PublicKeyMaterial, ...) bool
- func VerifyW3CProofDetailed(document map[string]any, publicKey anp.PublicKeyMaterial, ...) error
- type Error
- type GenerationOptions
- type IMGenerationOptions
- type IMProof
- type IMVerificationResult
- func VerifyIMProofWithDocument(proof IMProof, payload []byte, signatureBase []byte, ...) (IMVerificationResult, error)
- func VerifyIMProofWithDocumentForRelationship(proof IMProof, payload []byte, signatureBase []byte, ...) (IMVerificationResult, error)
- func VerifyIMProofWithVerificationMethod(proof IMProof, payload []byte, signatureBase []byte, ...) (IMVerificationResult, error)
- type ParsedIMSignatureInput
- type VerificationOptions
Constants ¶
const ( // IMProofRelationshipAuthentication binds request-level IM proofs to DID authentication. IMProofRelationshipAuthentication = "authentication" // IMProofRelationshipAssertionMethod binds assertion-style IM proofs to DID assertionMethod. IMProofRelationshipAssertionMethod = "assertionMethod" )
const ( ProofTypeSecp256k1 = "EcdsaSecp256k1Signature2019" ProofTypeEd25519 = "Ed25519Signature2020" ProofTypeDataIntegrity = "DataIntegrityProof" CryptosuiteEddsaJCS2022 = "eddsa-jcs-2022" CryptosuiteDidWbaSecp256k12025 = "didwba-jcs-ecdsa-secp256k1-2025" )
const GroupReceiptProofPurpose = "assertionMethod"
Variables ¶
var GroupReceiptRequiredFields = []string{
"receipt_type",
"group_did",
"group_state_version",
"subject_method",
"operation_id",
"actor_did",
"accepted_at",
"payload_digest",
}
var IMProofDefaultComponents = []string{"@method", "@target-uri", "content-digest"}
Functions ¶
func BuildIMContentDigest ¶
BuildIMContentDigest builds a content-digest header value for IM payloads.
func BuildIMSignatureInput ¶
func BuildIMSignatureInput(keyID string, options IMGenerationOptions) (string, error)
BuildIMSignatureInput builds an IM signature-input value.
func DecodeIMSignature ¶
DecodeIMSignature decodes a structured or bare signature value.
func EncodeIMSignature ¶
EncodeIMSignature encodes signature bytes into structured signature syntax.
func GenerateGroupReceiptProof ¶
func GenerateGroupReceiptProof(receipt map[string]any, privateKey anp.PrivateKeyMaterial, verificationMethod string) (map[string]any, error)
GenerateGroupReceiptProof signs a group receipt object.
func GenerateW3CProof ¶
func GenerateW3CProof(document map[string]any, privateKey anp.PrivateKeyMaterial, verificationMethod string, options GenerationOptions) (map[string]any, error)
GenerateW3CProof signs a JSON object and injects its proof object.
func VerifyGroupReceiptProof ¶
func VerifyGroupReceiptProof(receipt map[string]any, publicKey anp.PublicKeyMaterial) error
VerifyGroupReceiptProof verifies a signed group receipt.
func VerifyIMContentDigest ¶
VerifyIMContentDigest verifies a content-digest value.
func VerifyW3CProof ¶
func VerifyW3CProof(document map[string]any, publicKey anp.PublicKeyMaterial, options VerificationOptions) bool
VerifyW3CProof returns true when proof verification succeeds.
func VerifyW3CProofDetailed ¶
func VerifyW3CProofDetailed(document map[string]any, publicKey anp.PublicKeyMaterial, options VerificationOptions) error
VerifyW3CProofDetailed verifies a W3C proof and returns an error on failure.
Types ¶
type Error ¶
type Error struct {
Message string
}
Error reports proof generation or verification failures.
type GenerationOptions ¶
type GenerationOptions struct {
ProofPurpose string
ProofType string
Cryptosuite string
Created string
Domain string
Challenge string
}
GenerationOptions configures W3C proof generation.
type IMGenerationOptions ¶
type IMGenerationOptions struct {
Label string
Components []string
Created *int64
Expires *int64
Nonce string
}
IMGenerationOptions configures IM proof generation.
type IMProof ¶
type IMProof struct {
ContentDigest string `json:"contentDigest"`
SignatureInput string `json:"signatureInput"`
Signature string `json:"signature"`
}
IMProof stores an ANP IM business proof.
func GenerateIMProof ¶
func GenerateIMProof(payload []byte, signatureBase []byte, privateKey anp.PrivateKeyMaterial, keyID string, options IMGenerationOptions) (IMProof, error)
GenerateIMProof signs a prepared signature base and payload digest.
type IMVerificationResult ¶
type IMVerificationResult struct {
ParsedSignatureInput ParsedIMSignatureInput `json:"parsed_signature_input"`
VerificationMethod map[string]any `json:"verification_method"`
}
IMVerificationResult contains the verified verification method.
func VerifyIMProofWithDocument ¶
func VerifyIMProofWithDocument(proof IMProof, payload []byte, signatureBase []byte, didDocument map[string]any, expectedSignerDID string) (IMVerificationResult, error)
VerifyIMProofWithDocument verifies an IM proof using a DID document.
func VerifyIMProofWithDocumentForRelationship ¶
func VerifyIMProofWithDocumentForRelationship(proof IMProof, payload []byte, signatureBase []byte, didDocument map[string]any, expectedSignerDID string, verificationRelationship string) (IMVerificationResult, error)
VerifyIMProofWithDocumentForRelationship verifies an IM proof using a DID document and an explicit verification relationship.
func VerifyIMProofWithVerificationMethod ¶
func VerifyIMProofWithVerificationMethod(proof IMProof, payload []byte, signatureBase []byte, verificationMethod map[string]any, expectedSignerDID string) (IMVerificationResult, error)
VerifyIMProofWithVerificationMethod verifies an IM proof with an explicit verification method.
type ParsedIMSignatureInput ¶
type ParsedIMSignatureInput struct {
Label string `json:"label"`
Components []string `json:"components"`
SignatureParams string `json:"signature_params"`
KeyID string `json:"keyid"`
Nonce string `json:"nonce,omitempty"`
Created *int64 `json:"created,omitempty"`
Expires *int64 `json:"expires,omitempty"`
}
ParsedIMSignatureInput is the parsed signature-input structure.
func ParseIMSignatureInput ¶
func ParseIMSignatureInput(signatureInput string) (ParsedIMSignatureInput, error)
ParseIMSignatureInput parses a signature-input string.
type VerificationOptions ¶
type VerificationOptions struct {
ExpectedPurpose string
ExpectedDomain string
ExpectedChallenge string
}
VerificationOptions configures W3C proof verification.