@@ -15,74 +15,12 @@ import (
1515// Certificate represents a basic certificate in the wallet
1616type Certificate struct {
1717 Type [32 ]byte `json:"type"`
18- SerialNumber Bytes32Base64 `json:"serialNumber"`
18+ SerialNumber [ 32 ] byte `json:"serialNumber"`
1919 Subject * ec.PublicKey `json:"subject"`
2020 Certifier * ec.PublicKey `json:"certifier"`
2121 RevocationOutpoint * Outpoint `json:"revocationOutpoint,omitempty"`
2222 Fields map [string ]string `json:"fields,omitempty"` // Field name -> field value (encrypted)
23- Signature BytesHex `json:"signature,omitempty"`
24- }
25-
26- // MarshalJSON implements json.Marshaler interface for Certificate
27- func (c * Certificate ) MarshalJSON () ([]byte , error ) {
28- type Alias Certificate // Use alias to avoid recursion
29- var subjectHex , certifierHex * string
30- if c .Subject != nil {
31- s := c .Subject .ToDERHex ()
32- subjectHex = & s
33- }
34- if c .Certifier != nil {
35- cs := c .Certifier .ToDERHex ()
36- certifierHex = & cs
37- }
38-
39- return json .Marshal (& struct {
40- Type Bytes32Base64 `json:"type"`
41- Subject * string `json:"subject"`
42- Certifier * string `json:"certifier"`
43- * Alias
44- }{
45- Type : c .Type ,
46- Subject : subjectHex ,
47- Certifier : certifierHex ,
48- Alias : (* Alias )(c ),
49- })
50- }
51-
52- // UnmarshalJSON implements json.Unmarshaler interface for Certificate
53- func (c * Certificate ) UnmarshalJSON (data []byte ) error {
54- type Alias Certificate // Use alias to avoid recursion
55- aux := & struct {
56- Type Bytes32Base64 `json:"type"`
57- Subject * string `json:"subject"`
58- Certifier * string `json:"certifier"`
59- * Alias
60- }{
61- Alias : (* Alias )(c ),
62- }
63-
64- if err := json .Unmarshal (data , & aux ); err != nil {
65- return fmt .Errorf ("error unmarshaling certificate: %w" , err )
66- }
67-
68- // Decode public key hex strings
69- if aux .Subject != nil {
70- sub , err := ec .PublicKeyFromString (* aux .Subject )
71- if err != nil {
72- return fmt .Errorf ("error decoding subject public key hex: %w" , err )
73- }
74- c .Subject = sub
75- }
76- if aux .Certifier != nil {
77- cert , err := ec .PublicKeyFromString (* aux .Certifier )
78- if err != nil {
79- return fmt .Errorf ("error decoding certifier public key hex: %w" , err )
80- }
81- c .Certifier = cert
82- }
83- c .Type = aux .Type
84-
85- return nil
23+ Signature []byte `json:"signature,omitempty"`
8624}
8725
8826func (c * Certificate ) RevocationOutpointString () string {
@@ -632,10 +570,10 @@ func (r *KeyringRevealer) UnmarshalJSON(data []byte) error {
632570// This includes the certificate type, certifier information, and acquisition method.
633571type AcquireCertificateArgs struct {
634572 Type [32 ]byte `json:"type"`
635- Certifier Bytes33Hex `json:"certifier"`
573+ Certifier [ 33 ] byte `json:"certifier"`
636574 AcquisitionProtocol AcquisitionProtocol `json:"acquisitionProtocol"` // "direct" | "issuance"
637575 Fields map [string ]string `json:"fields,omitempty"`
638- SerialNumber Bytes32Base64 `json:"serialNumber"`
576+ SerialNumber [ 32 ] byte `json:"serialNumber"`
639577 RevocationOutpoint * Outpoint `json:"revocationOutpoint,omitempty"`
640578 Signature BytesHex `json:"signature,omitempty"`
641579 CertifierUrl string `json:"certifierUrl,omitempty"`
@@ -645,35 +583,6 @@ type AcquireCertificateArgs struct {
645583 PrivilegedReason string `json:"privilegedReason,omitempty"`
646584}
647585
648- func (a * AcquireCertificateArgs ) UnmarshalJSON (data []byte ) error {
649- type Alias AcquireCertificateArgs
650- aux := & struct {
651- Type Bytes32Base64 `json:"type"`
652- * Alias
653- }{
654- Alias : (* Alias )(a ),
655- }
656-
657- if err := json .Unmarshal (data , & aux ); err != nil {
658- return fmt .Errorf ("error unmarshaling AcquireCertificateArgs: %w" , err )
659- }
660-
661- a .Type = aux .Type
662-
663- return nil
664- }
665-
666- func (a * AcquireCertificateArgs ) MarshalJSON () ([]byte , error ) {
667- type Alias AcquireCertificateArgs
668- return json .Marshal (& struct {
669- Type Bytes32Base64 `json:"type"`
670- * Alias
671- }{
672- Type : Bytes32Base64 (a .Type [:]),
673- Alias : (* Alias )(a ),
674- })
675- }
676-
677586// ListCertificatesArgs contains parameters for listing certificates with filtering and pagination.
678587type ListCertificatesArgs struct {
679588 Certifiers []Bytes33Hex `json:"certifiers"`
0 commit comments