diff --git a/credentialAtomicQueryV3.go b/credentialAtomicQueryV3.go index 901761e..8f5d704 100644 --- a/credentialAtomicQueryV3.go +++ b/credentialAtomicQueryV3.go @@ -129,6 +129,10 @@ func (a AtomicQueryV3Inputs) Validate() error { switch a.ProofType { case SigProotType: + if a.Claim.SignatureProof == nil { + return errors.New(ErrorEmptySignatureProof) + } + if a.Claim.SignatureProof.IssuerAuthIncProof.Proof == nil { return errors.New(ErrorEmptyIssuerAuthClaimProof) } @@ -141,6 +145,10 @@ func (a AtomicQueryV3Inputs) Validate() error { return errors.New(ErrorEmptyClaimSignature) } case MTPProofType: + if a.Claim.IncProof == nil { + return errors.New(ErrorEmptyMTPProof) + } + if a.Claim.IncProof.Proof == nil { return errors.New(ErrorEmptyClaimProof) } @@ -212,6 +220,10 @@ func (a AtomicQueryV3Inputs) InputsMarshal() ([]byte, error) { case SigProotType: s.ProofType = "1" + if a.Claim.SignatureProof == nil { + return nil, errors.New(ErrorEmptySignatureProof) + } + s.IssuerClaimSignatureR8X = a.Claim.SignatureProof.Signature.R8.X.String() s.IssuerClaimSignatureR8Y = a.Claim.SignatureProof.Signature.R8.Y.String() s.IssuerClaimSignatureS = a.Claim.SignatureProof.Signature.S.String() @@ -235,6 +247,10 @@ func (a AtomicQueryV3Inputs) InputsMarshal() ([]byte, error) { case MTPProofType: s.ProofType = "2" + if a.Claim.IncProof == nil { + return nil, errors.New(ErrorEmptyMTPProof) + } + s.IssuerClaimMtp = CircomSiblings(a.Claim.IncProof.Proof, a.GetMTLevel()) s.IssuerClaimClaimsTreeRoot = a.Claim.IncProof.TreeState.ClaimsRoot s.IssuerClaimRevTreeRoot = a.Claim.IncProof.TreeState.RevocationRoot diff --git a/credentialAtomicQueryV3OnChain.go b/credentialAtomicQueryV3OnChain.go index 1a70051..53efc93 100644 --- a/credentialAtomicQueryV3OnChain.go +++ b/credentialAtomicQueryV3OnChain.go @@ -185,6 +185,10 @@ func (a AtomicQueryV3OnChainInputs) Validate() error { switch a.ProofType { case SigProotType: + if a.Claim.SignatureProof == nil { + return errors.New(ErrorEmptySignatureProof) + } + if a.Claim.SignatureProof.IssuerAuthIncProof.Proof == nil { return errors.New(ErrorEmptyIssuerAuthClaimProof) } @@ -197,6 +201,10 @@ func (a AtomicQueryV3OnChainInputs) Validate() error { return errors.New(ErrorEmptyClaimSignature) } case MTPProofType: + if a.Claim.IncProof == nil { + return errors.New(ErrorEmptyMTPProof) + } + if a.Claim.IncProof.Proof == nil { return errors.New(ErrorEmptyClaimProof) } @@ -285,6 +293,10 @@ func (a AtomicQueryV3OnChainInputs) InputsMarshal() ([]byte, error) { case SigProotType: s.ProofType = "1" + if a.Claim.SignatureProof == nil { + return nil, errors.New(ErrorEmptySignatureProof) + } + s.IssuerClaimSignatureR8X = a.Claim.SignatureProof.Signature.R8.X.String() s.IssuerClaimSignatureR8Y = a.Claim.SignatureProof.Signature.R8.Y.String() s.IssuerClaimSignatureS = a.Claim.SignatureProof.Signature.S.String() @@ -308,6 +320,10 @@ func (a AtomicQueryV3OnChainInputs) InputsMarshal() ([]byte, error) { case MTPProofType: s.ProofType = "2" + if a.Claim.IncProof == nil { + return nil, errors.New(ErrorEmptyMTPProof) + } + s.IssuerClaimMtp = CircomSiblings(a.Claim.IncProof.Proof, a.GetMTLevel()) s.IssuerClaimClaimsTreeRoot = a.Claim.IncProof.TreeState.ClaimsRoot s.IssuerClaimRevTreeRoot = a.Claim.IncProof.TreeState.RevocationRoot diff --git a/credentialAtomicQueryV3OnChain_test.go b/credentialAtomicQueryV3OnChain_test.go index f3c68fa..5ffe635 100644 --- a/credentialAtomicQueryV3OnChain_test.go +++ b/credentialAtomicQueryV3OnChain_test.go @@ -62,7 +62,7 @@ func TestAttrQueryV3OnChain_SigPart_PrepareInputs(t *testing.T) { }, Proof: issuerClaimNonRevMtp, }, - SignatureProof: BJJSignatureProof{ + SignatureProof: &BJJSignatureProof{ Signature: claimSig, IssuerAuthClaim: issuer.AuthClaim, IssuerAuthIncProof: MTProof{ @@ -157,7 +157,7 @@ func TestAttrQueryV3OnChain_MTPPart_PrepareInputs(t *testing.T) { Claim: ClaimWithSigAndMTPProof{ IssuerID: &issuer.ID, Claim: claim, - IncProof: MTProof{ + IncProof: &MTProof{ Proof: issuerClaimMtp, TreeState: TreeState{ State: issuer.State(t), diff --git a/credentialAtomicQueryV3_test.go b/credentialAtomicQueryV3_test.go index eb62c88..4ef8ee4 100644 --- a/credentialAtomicQueryV3_test.go +++ b/credentialAtomicQueryV3_test.go @@ -48,7 +48,7 @@ func TestAttrQueryV3_SigPart_PrepareInputs(t *testing.T) { }, Proof: issuerClaimNonRevMtp, }, - SignatureProof: BJJSignatureProof{ + SignatureProof: &BJJSignatureProof{ Signature: claimSig, IssuerAuthClaim: issuer.AuthClaim, IssuerAuthIncProof: MTProof{ @@ -120,7 +120,7 @@ func TestAttrQueryV3_MTPPart_PrepareInputs(t *testing.T) { Claim: ClaimWithSigAndMTPProof{ IssuerID: &issuer.ID, Claim: claim, - IncProof: MTProof{ + IncProof: &MTProof{ Proof: issuerClaimMtp, TreeState: TreeState{ State: issuer.State(t), diff --git a/errors.go b/errors.go index 09e8b35..233a0a6 100644 --- a/errors.go +++ b/errors.go @@ -22,4 +22,6 @@ const ( ErrorEmptyGISTProof = "empty GIST identity mtp proof" ErrorEmptyRequestID = "empty request ID" ErrorInvalidProofType = "invalid proof type" + ErrorEmptySignatureProof = "empty signature proof" + ErrorEmptyMTPProof = "empty MTP proof" ) diff --git a/types.go b/types.go index 53ba458..fca7b73 100644 --- a/types.go +++ b/types.go @@ -7,11 +7,11 @@ import ( ) type ClaimWithSigAndMTPProof struct { - IssuerID *core.ID `json:"issuerID"` - Claim *core.Claim `json:"claim"` - NonRevProof MTProof `json:"nonRevProof"` // Claim non revocation proof - SignatureProof BJJSignatureProof `json:"signatureProof"` - IncProof MTProof `json:"incProof"` // proof of inclusion `Claim` to the issuer claims tree + IssuerID *core.ID `json:"issuerID"` + Claim *core.Claim `json:"claim"` + NonRevProof MTProof `json:"nonRevProof"` // Claim non revocation proof + SignatureProof *BJJSignatureProof `json:"signatureProof"` + IncProof *MTProof `json:"incProof"` // proof of inclusion `Claim` to the issuer claims tree } type ClaimWithSigProof struct {