Skip to content

Commit ed781b1

Browse files
committed
Make Linkage counterparty the right type
1 parent d8cbe4e commit ed781b1

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

wallet/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ type RevealSpecificKeyLinkageResult struct {
419419
EncryptedLinkageProof []byte `json:"encryptedLinkageProof"`
420420
Prover *ec.PublicKey `json:"prover"`
421421
Verifier *ec.PublicKey `json:"verifier"`
422-
Counterparty Counterparty `json:"counterparty"`
422+
Counterparty *ec.PublicKey `json:"counterparty"`
423423
ProtocolID Protocol `json:"protocolID"`
424424
KeyID string `json:"keyID"`
425425
ProofType byte `json:"proofType"`

wallet/serializer/reveal_specific_key_linkage.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ func SerializeRevealSpecificKeyLinkageResult(result *wallet.RevealSpecificKeyLin
7575
return nil, fmt.Errorf("verifier public key is required")
7676
}
7777
w.WriteBytes(result.Verifier.Compressed())
78-
if err := encodeCounterparty(w, result.Counterparty); err != nil {
79-
return nil, fmt.Errorf("error encoding counterparty: %w", err)
78+
if result.Counterparty == nil {
79+
return nil, fmt.Errorf("counterparty public key is required")
8080
}
81+
w.WriteBytes(result.Counterparty.Compressed())
8182

8283
// Write protocol ID (security level + protocol string)
8384
w.WriteBytes(encodeProtocol(result.ProtocolID))
@@ -110,9 +111,9 @@ func DeserializeRevealSpecificKeyLinkageResult(data []byte) (*wallet.RevealSpeci
110111
}
111112
result.Verifier = verifier
112113

113-
counterparty, err := decodeCounterparty(r)
114+
counterparty, err := ec.PublicKeyFromBytes(r.ReadBytes(sizePubKey))
114115
if err != nil {
115-
return nil, fmt.Errorf("error decoding counterparty: %w", err)
116+
return nil, fmt.Errorf("error parsing counterparty public key: %w", err)
116117
}
117118
result.Counterparty = counterparty
118119

wallet/serializer/reveal_specific_key_linkage_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestRevealSpecificKeyLinkageResult(t *testing.T) {
7070
result: &wallet.RevealSpecificKeyLinkageResult{
7171
Prover: tu.GetPKFromHex(t, "03d4f6b2d5e6c8a9b0f7e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687"),
7272
Verifier: tu.GetPKFromHex(t, "02c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2"),
73-
Counterparty: newCounterparty(t, "03f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687"),
73+
Counterparty: tu.GetPKFromHex(t, "03f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687"),
7474
ProtocolID: wallet.Protocol{
7575
SecurityLevel: wallet.SecurityLevel(1),
7676
Protocol: "test-protocol",
@@ -86,7 +86,7 @@ func TestRevealSpecificKeyLinkageResult(t *testing.T) {
8686
result: &wallet.RevealSpecificKeyLinkageResult{
8787
Prover: tu.GetPKFromHex(t, "03d4f6b2d5e6c8a9b0f7e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687"),
8888
Verifier: tu.GetPKFromHex(t, "02c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2"),
89-
Counterparty: newCounterparty(t, "03f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687"),
89+
Counterparty: tu.GetPKFromHex(t, "03f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687f0e1d2c3b4a59687"),
9090
ProtocolID: wallet.Protocol{
9191
SecurityLevel: wallet.SecurityLevel(0),
9292
Protocol: "minimal",

wallet/substrates/vector_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,7 @@ func TestVectors(t *testing.T) {
277277
EncryptedLinkageProof: []byte{5, 6, 7, 8},
278278
Prover: prover,
279279
Verifier: verifier,
280-
Counterparty: wallet.Counterparty{
281-
Type: wallet.CounterpartyTypeOther,
282-
Counterparty: counterparty,
283-
},
280+
Counterparty: counterparty,
284281
ProtocolID: wallet.Protocol{
285282
SecurityLevel: wallet.SecurityLevelEveryAppAndCounterparty,
286283
Protocol: "tests",

0 commit comments

Comments
 (0)