Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using of _basePoint #9

Open
wasimjee opened this issue Jan 11, 2016 · 4 comments
Open

Using of _basePoint #9

wasimjee opened this issue Jan 11, 2016 · 4 comments

Comments

@wasimjee
Copy link

i need to get public key using the _basePoint, but i see nowhere, u using it,

Please prove solution.

  1. Generating Random Privatekey.
  2. Generating Public Key using Privatekey and _basePoint
@CodesInChaos
Copy link
Owner

For montgomery form Curve25519 you can use MontgomeryCurve25519.GetPublicKey. Use a random 32 byte value as private key. Note that this twiddles some bits to match NaCl, so it doesn't work with computed scalars.

For Ed25519 you can use Ed25519.KeyPairFromSeed or (PublicKeyFromSeed and ExpandedPrivateKeyFromSeed) to generate a key-pair. Use a random 32 byte value as privateKeySeed.

Internally I'm using a specialized method for multiplying with the base point, which is about twice as fast as using a general purpose scalar multiplication routine and passing it the base point.

To generate those random 32 byte values you can use a function like:

public static byte[] GetRandomBytes(int length)
{
    using(var rng = new RNGCryptoServiceProvider())
    {
        var bytes = new byte[length];
        rng.GetBytes(bytes);
        return bytes;
    }
}

I didn't include this in my library because it's only available in some flavours of the .net framework.

@wasimjee
Copy link
Author

@CodesInChaos , Thanks for your Help,

I got the required Result.

@wasimjee
Copy link
Author

Have 2 more queries

  1. Regarding Creating Signature
  2. Regarding Verifying the Created Signature.

i am not able to get.

Please provide a solution

@CodesInChaos
Copy link
Owner

byte[] publicKey, privateKey;
Ed25519.KeyPairFromSeed(out publicKey, out privateKey, GetRandomBytes(32));
byte[] signature = Ed25519.Sign(message, privateKey);
bool isValid = Ed25519.Verify(signature, message, publicKey);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants