Hot answers tagged

16

Stellar is using Ed25519 public-key signature system. After generating a new key pair (public and private key), both keys are strkey-encoded. strkey works like this: Prepend keys with a version byte: public key with 6 << 3 byte (decimal: 48, this later encodes to letter G), private key with 18 << 3 byte (decimal: 144, this later encodes to ...


13

No special meaning, it's just a side effect of base32 encoding: the first byte (8 bits) that is encoded contains the type of the string. A public key has prefix "G" for example. You can see the others there. when converting into base32 the data is consumed 5 bits at a time, so the first 5 bits of the 8 bits version end up being the first character. The ...


13

If you are using Stellar JS SDK, the following method will work for you. import StellarBase from 'stellar-base' if (StellarBase.StrKey.isValidEd25519SecretSeed('SB....4A')) { //secret key is valid } if (StellarBase.StrKey.isValidEd25519PublicKey('GA....6C')) { //public key is valid }


12

If you're just interested in checking whether it's a well-formed key, you can use the following algorithm: Verify that the string starts with "S" Base-32 decode the S... string to get the raw bytes. You will end up with 35 bytes. Ignore the first byte since it represents the "S". Calculate the CRC-16 checksum of the next 32 bytes. These bytes represent the ...


8

I'm working on a Rust library so I had to implement this as well. If you have a 32 byte secret seed, you can generate the ED25519 keypair using your favorite crypto library. Likewise for public keys only. How to convert the secret and account id to bytes Good reference for this operation is strkey in js-stellar-base, you want to look at ...


6

It's always 56 for the current encoding scheme. And there is no intention to change the keypair generation mechanism in the nearest future, as far as I know. The invention of the relatively cheap quantum computers with more than 100 qubits may lead to cryptography schemes reconsideration. But they won't be available for at least 2-3 years. Therefore, you ...


4

Firstly check these posts to see how the public address is constructed :- Which cryptographic algorithm is used to generate the secret and public keys? How can I decode Ed25519 addresses to the regular 56 letters format? Now use a Base32 calculator (eg this one :- Perl CPAN module "Karel Miko > CryptX-0.057 > Crypt::Misc" function encode_b32r, or this :- ...


3

Accounts do not exist until they have received their initial funding with a CreateAccount operation. A payment sent to an account that does not yet exist will fail. A valid payment sent to an account that has been created will succeed. The sender must ensure the account number is correct before submitting the transaction.


3

You can use StrKey.decodeStellarAccountId() wrapped with a try-catch block. If the expression throws an exception, the account id is invalid.


2

You will need to verify the signature against the signing key (account ID). You can take a look at how the compliance server implements signature verification. Copying over the code (Golang) here for convenience: // VerifySignature verifies if signature is valid. It makes a network connection // to sender server in order to obtain stellar.toml file and ...


2

The easiest way is to compare the transaction hashes - if they are the same then it was not modified. Signatures are used to prove that a given user signed a transaction (and actually what is being signed is the transaction hash). You could do what you’re suggesting about using verify, but it’s a roundabout way of doing it. Regarding your code - it doesn’t ...


1

Short answer: the keypair never expires. Since the public key is essentially a computational result of so called one-way function, the public key can be derived from the secret key itself. Therefore, the term "keypair" refers to a pair of a secret key and complementary public key that can be regenerated from a secret key. The keypair is generated ...


1

try to validate the transaction hash tx_hash_32, err := tx.Hash() if err != nil { panic(err) } tx_hash := tx_hash_32[:] err = destinationPair.Verify(tx_hash, txs.E.Signatures[0].Signature) if err != nil { panic(err) // panics here with signature verification failed } fmt.Printf("success\n")


1

DeadObjectException is a side-effect of some other failure. Can you debug the root cause by placing a try-catch-log block around KeyPair.random? Aside #1: The implementation of KeyPair.random is entirely dependent on the net.i2p.crypto library, so you may be able to cut down the dependencies required to reproduce this. Aside #2: A recent pull request to ...


Only top voted, non community-wiki answers of a minimum length are eligible