pmarches / jStellarAPI

java API for the stellar network
GNU Lesser General Public License v3.0
15 stars 3 forks source link

Unable to sign transactions locally. #25

Open jojopoper opened 9 years ago

jojopoper commented 9 years ago

I got the master version jstellarAPI java code , and create a private key and public key, then I want to signed a wallet ,but has error

this is my test code =========================Test code Begin=========================== StellarBinaryObject rbo = null; try { BigInteger iSTRAmount = new BigInteger("100"); String randomStr1 = "1234567890abcdefgqwertyuiopasdfg"; DenominatedIssuedCurrency amount = new DenominatedIssuedCurrency(iSTRAmount); StellarSeedAddress seed1 = new StellarSeedAddress(randomStr1.getBytes()); StellarAddress payee = new StellarAddress("gnCLrAVyhjsLzQmudwzJycr84fCCHaigVJ"); int nextTransactionSequenceNumber = 10; StellarPaymentTransaction tx = new StellarPaymentTransaction(seed1.getPublicStellarAddress(), payee, amount, nextTransactionSequenceNumber); //TODO Compute the required fee from the server_info tx.fee = new DenominatedIssuedCurrency(new BigInteger("10")); rbo = tx.getBinaryObject(); rbo = new StellarSigner(seed1.getPrivateKey()).sign(rbo); // <----here is error occurs } catch (Exception e){ e.printStackTrace(); return; } byte[] signedTXBytes = new StellarBinarySerializer().writeBinaryObject(rbo).array();

=========================Test code end===========================

The error message is : java.lang.IllegalArgumentException: Invalid point encoding 0x79 at org.bouncycastle.math.ec.ECCurve.decodePoint(Unknown Source) at jstellarapi.core.StellarPublicKey.getPublicPoint(StellarPublicKey.java:39) at jstellarapi.keys.StellarSigner.sign(StellarSigner.java:39) at jstellarapi.cli.JStellarCliMain.main(JStellarCliMain.java:71)

pls help me , what is wrong in my java code? thank you!

pmarches commented 9 years ago

Hi,

Unfortunatly, it seems signing does not work properly since the move from ripple to stellar. Stellar uses a different EC curve than Ripple. I do not have time to fix this, but you are welcomed to try your hand at it.

I would start by getting rid of the ECPoint references since they are BouncyCastle specific.Also get rid of StellarDeterministicKeyGenerator.SECP256K1_PARAMS which is the old ripple curve. Stellar uses the ed25519-sha-512 curve. Work you way up to the signing portion of the code, which you may have to also change.

Alternatively, you may ask the server to sign the transaction for you.

Regards, Philippe

jojopoper commented 9 years ago

Thank you very much pmarches . I think about how to modify my code. ;)