diff --git a/src/main/java/org/stellar/sdk/Auth.java b/src/main/java/org/stellar/sdk/Auth.java index d5f00c511..aa0d20ce5 100644 --- a/src/main/java/org/stellar/sdk/Auth.java +++ b/src/main/java/org/stellar/sdk/Auth.java @@ -94,7 +94,7 @@ public static SorobanAuthorizationEntry authorizeEntry( } byte[] payload = Util.hash(data); byte[] signature = signer.sign(payload); - return new Signature(signer.getPublicKey(), signature); + return new Signature(signer.getAccountId(), signature); }; return authorizeEntry(entry, entrySigner, validUntilLedgerSeq, network); @@ -196,7 +196,8 @@ public static SorobanAuthorizationEntry authorizeEntry( throw new IllegalArgumentException("Unable to convert preimage to bytes", e); } byte[] payload = Util.hash(data); - if (!KeyPair.fromPublicKey(signature.publicKey).verify(payload, signature.signature)) { + KeyPair kp = KeyPair.fromAccountId(signature.publicKey); + if (!kp.verify(payload, signature.signature)) { throw new IllegalArgumentException("signature does not match payload"); } @@ -207,7 +208,7 @@ public static SorobanAuthorizationEntry authorizeEntry( Scv.toMap( new LinkedHashMap() { { - put(Scv.toSymbol("public_key"), Scv.toBytes(signature.getPublicKey())); + put(Scv.toSymbol("public_key"), Scv.toBytes(kp.getPublicKey())); put(Scv.toSymbol("signature"), Scv.toBytes(signature.getSignature())); } }); @@ -247,7 +248,7 @@ public static SorobanAuthorizationEntry authorizeInvocation( try { byte[] payload = Util.hash(preimage.toXdrByteArray()); byte[] signature = signer.sign(payload); - return new Signature(signer.getPublicKey(), signature); + return new Signature(signer.getAccountId(), signature); } catch (IOException e) { throw new UnexpectedException(e); } @@ -309,7 +310,7 @@ public static SorobanAuthorizationEntry authorizeInvocation( /** A signature, consisting of a public key and a signature. */ @Value public static class Signature { - byte[] publicKey; + String publicKey; byte[] signature; } diff --git a/src/test/java/org/stellar/sdk/AuthTest.java b/src/test/java/org/stellar/sdk/AuthTest.java index 01917bf90..793c13847 100644 --- a/src/test/java/org/stellar/sdk/AuthTest.java +++ b/src/test/java/org/stellar/sdk/AuthTest.java @@ -220,7 +220,7 @@ public void testSignAuthorizeEntryWithBase64EntryAndFunctionSigner() throws IOEx } byte[] payload = Util.hash(data); byte[] signature = signer.sign(payload); - return new Auth.Signature(signer.getPublicKey(), signature); + return new Auth.Signature(signer.getAccountId(), signature); }; long validUntilLedgerSeq = 654656L; Network network = Network.TESTNET; @@ -321,7 +321,7 @@ public void testSignAuthorizeEntryWithXdrEntryAndFunctionSigner() throws IOExcep } byte[] payload = Util.hash(data); byte[] signature = signer.sign(payload); - return new Auth.Signature(signer.getPublicKey(), signature); + return new Auth.Signature(signer.getAccountId(), signature); }; long validUntilLedgerSeq = 654656L; Network network = Network.TESTNET; @@ -455,7 +455,7 @@ public void testSignAuthorizeEntryWithSignatureMismatchThrows() throws IOExcepti preimage -> { byte[] invalidData = new byte[20]; byte[] signature = signer.sign(invalidData); - return new Auth.Signature(signer.getPublicKey(), signature); + return new Auth.Signature(signer.getAccountId(), signature); }; long validUntilLedgerSeq = 654656L; Network network = Network.TESTNET; @@ -565,7 +565,7 @@ public void authorizeInvocationWithFunctionSigner() { } byte[] payload = Util.hash(data); byte[] signature = signer.sign(payload); - return new Auth.Signature(signer.getPublicKey(), signature); + return new Auth.Signature(signer.getAccountId(), signature); }; long validUntilLedgerSeq = 654656L; Network network = Network.TESTNET; @@ -720,7 +720,7 @@ public void testSignAuthorizeEntryWithFunctionSignerNotEqualCredentialAddress() } byte[] payload = Util.hash(data); byte[] signature = signer.sign(payload); - return new Auth.Signature(signer.getPublicKey(), signature); + return new Auth.Signature(signer.getAccountId(), signature); }; long validUntilLedgerSeq = 654656L; Network network = Network.TESTNET;