You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should be relatively easy because there's good code in crypto/curve25519/curve25519.c that can be used. Actually, in src/ec/eddsa.rs, there is already a function named ed25519_sign that implements the signing. So, the bulk of this work is just implementing the ring::signature::SigningKey API that is consistent with the rest of ring, and then adding ring::signature::ED25519_SIGNING.
The tricky part is that there's no code to load a serialized private key, and there's no way to serialize a private key, which would be important to many uses. Deserialization and serialization could be done as a follow-on.
See also any general notes about signing APIs in #205.
If you're interested in working on this, I suggest that you just try to implement SigningKey in the most simple way possible, hard-coding Ed25519 (and SHA-512). Then we can evolve the API from there.
For example, instead of trying to define a generic SigningKey type and a generic sign function, we can have an Ed25519KeyPair struct with methods like this:
// A wrapper around an array of bytes, very much like digest::Digest.
struct Signature {
...
}
impl Ed25519KeyPair<'a> {
fn generate(rng: &SecureRandom) -> Result<Ed25519KeyPair, ()>,
fn from_bytes(private_key: &[u8], public_key: &[u8]) -> Result<Ed25519KeyPair, ()>,
fn private_key_bytes() -> &'a [u8],
fn public_key_bytes() -> &'a [u8],
fn sign(&self, msg: Input) -> Signature,
}
Note: Ed25519KeyPair and all the code should be in ring::ec::eddsa. Then, ring::signature should pub use ec::eddsa::Ed25519KeyPair to expose it in the public API.
Tests (I think there are already tests existing, using the private ed25519_sign function; they may just need to be adapted.)
Add documentation, including a full example. (Note: the example should use signature::Ed25519SKeyPair, not ec::eddsa::Ed25519KeyPair. Also, you need to temporarily flip the doctests on in Cargo.toml; they are disabled because they brea cross-compiling.)
I'm going to close this, since the only thing left on the checklist is the benchmarks, and crypto-bench already is keeping track of what needs to be done. Thanks again @djc.
Activity
djc commentedon Jun 2, 2016
So without ser/de, what does the SigningKey instantiation look like? Just a 64-element u8 slice?
briansmith commentedon Jun 2, 2016
Should it be a 64-element u8 slice, or two 32-element u8 slices, one for the private part and one for the public part?
Anyway, yes, at least until we have deserialization and serialization support, setting the key via a slice or slices is fine.
briansmith commentedon Jun 4, 2016
If you're interested in working on this, I suggest that you just try to implement SigningKey in the most simple way possible, hard-coding Ed25519 (and SHA-512). Then we can evolve the API from there.
For example, instead of trying to define a generic
SigningKeytype and a genericsignfunction, we can have anEd25519KeyPairstruct with methods like this:briansmith commentedon Jun 4, 2016
Note:
Ed25519KeyPairand all the code should be inring::ec::eddsa. Then,ring::signatureshouldpub use ec::eddsa::Ed25519KeyPairto expose it in the public API.[Edit: s/agreement/signature/]
briansmith commentedon Jun 4, 2016
Rough Steps:
Ed25519KeyPaired25519_signfunction; they may just need to be adapted.)signature::Ed25519SKeyPair, notec::eddsa::Ed25519KeyPair. Also, you need to temporarily flip the doctests on in Cargo.toml; they are disabled because they brea cross-compiling.)[Edit: s/agreement/signature/]
[-]Add EdDSA signing support[/-][+]Add Ed25519 signing support[/+]briansmith commentedon Jun 6, 2016
I'm going to close this, since the only thing left on the checklist is the benchmarks, and crypto-bench already is keeping track of what needs to be done. Thanks again @djc.