@@ -14,7 +14,7 @@ import (
1414
1515// Certificate represents a basic certificate in the wallet
1616type Certificate struct {
17- Type Bytes32Base64 `json:"type"`
17+ Type [ 32 ] byte `json:"type"`
1818 SerialNumber Bytes32Base64 `json:"serialNumber"`
1919 Subject * ec.PublicKey `json:"subject"`
2020 Certifier * ec.PublicKey `json:"certifier"`
@@ -37,10 +37,12 @@ func (c *Certificate) MarshalJSON() ([]byte, error) {
3737 }
3838
3939 return json .Marshal (& struct {
40- Subject * string `json:"subject"`
41- Certifier * string `json:"certifier"`
40+ Type Bytes32Base64 `json:"type"`
41+ Subject * string `json:"subject"`
42+ Certifier * string `json:"certifier"`
4243 * Alias
4344 }{
45+ Type : c .Type ,
4446 Subject : subjectHex ,
4547 Certifier : certifierHex ,
4648 Alias : (* Alias )(c ),
@@ -51,8 +53,9 @@ func (c *Certificate) MarshalJSON() ([]byte, error) {
5153func (c * Certificate ) UnmarshalJSON (data []byte ) error {
5254 type Alias Certificate // Use alias to avoid recursion
5355 aux := & struct {
54- Subject * string `json:"subject"`
55- Certifier * string `json:"certifier"`
56+ Type Bytes32Base64 `json:"type"`
57+ Subject * string `json:"subject"`
58+ Certifier * string `json:"certifier"`
5659 * Alias
5760 }{
5861 Alias : (* Alias )(c ),
@@ -77,6 +80,7 @@ func (c *Certificate) UnmarshalJSON(data []byte) error {
7780 }
7881 c .Certifier = cert
7982 }
83+ c .Type = aux .Type
8084
8185 return nil
8286}
@@ -627,7 +631,7 @@ func (r *KeyringRevealer) UnmarshalJSON(data []byte) error {
627631// AcquireCertificateArgs contains parameters for acquiring a new certificate.
628632// This includes the certificate type, certifier information, and acquisition method.
629633type AcquireCertificateArgs struct {
630- Type Bytes32Base64 `json:"type"`
634+ Type [ 32 ] byte `json:"type"`
631635 Certifier Bytes33Hex `json:"certifier"`
632636 AcquisitionProtocol AcquisitionProtocol `json:"acquisitionProtocol"` // "direct" | "issuance"
633637 Fields map [string ]string `json:"fields,omitempty"`
@@ -641,6 +645,35 @@ type AcquireCertificateArgs struct {
641645 PrivilegedReason string `json:"privilegedReason,omitempty"`
642646}
643647
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+
644677// ListCertificatesArgs contains parameters for listing certificates with filtering and pagination.
645678type ListCertificatesArgs struct {
646679 Certifiers []Bytes33Hex `json:"certifiers"`
@@ -724,11 +757,42 @@ type ListCertificatesResult struct {
724757
725758// RelinquishCertificateArgs contains parameters for relinquishing ownership of a certificate.
726759type RelinquishCertificateArgs struct {
727- Type Bytes32Base64 `json:"type"`
760+ Type [ 32 ] byte `json:"type"`
728761 SerialNumber Bytes32Base64 `json:"serialNumber"`
729762 Certifier Bytes33Hex `json:"certifier"`
730763}
731764
765+ func (r * RelinquishCertificateArgs ) UnmarshalJSON (data []byte ) error {
766+ // Unmarshal into a temporary struct to handle the Bytes32Base64 type
767+ type Alias RelinquishCertificateArgs
768+ aux := & struct {
769+ Type Bytes32Base64 `json:"type"`
770+ * Alias
771+ }{
772+ Alias : (* Alias )(r ),
773+ }
774+
775+ if err := json .Unmarshal (data , & aux ); err != nil {
776+ return fmt .Errorf ("error unmarshaling RelinquishCertificateArgs: %w" , err )
777+ }
778+
779+ r .Type = aux .Type
780+
781+ return nil
782+ }
783+
784+ func (r * RelinquishCertificateArgs ) MarshalJSON () ([]byte , error ) {
785+ // Marshal the Type as Bytes32Base64
786+ type Alias RelinquishCertificateArgs
787+ return json .Marshal (& struct {
788+ Type Bytes32Base64 `json:"type"`
789+ * Alias
790+ }{
791+ Type : Bytes32Base64 (r .Type [:]),
792+ Alias : (* Alias )(r ),
793+ })
794+ }
795+
732796// RelinquishOutputArgs contains parameters for relinquishing ownership of an output.
733797type RelinquishOutputArgs struct {
734798 Basket string `json:"basket"`
0 commit comments