Skip to content

Commit

Permalink
Ed25519 vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Jun 20, 2024
1 parent 9751f58 commit b72900d
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 8 deletions.
80 changes: 80 additions & 0 deletions data/ed25519_sha512_tai_vectors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[
{
"comment": "ed25519-sha512-tai vector-0",
"sk": "b48e913135c9b4f3b1f827e9078b194cc22e2081e8658a515961ee7f5b4e8206",
"pk": "6df1619a1ef5fc4e53a03ddb1c26f568978415612eae3a3072370898bcd4ba21",
"alpha": "",
"ad": "",
"h": "63235208358694eefe50d23c068414f3c906460187b3fef0f9abec29b2c83896",
"gamma": "96bbfdc967a99035133f4c793e72125c0fba916062ec14b45ffcc1cc13fd2189",
"beta": "bc4c45ec038b4cbbf24594c6766ab09f39de276d521b8a1384b0eeceb9a41a2e1c8f3902a283e56ac2c63933c3bbc917f29e45f8afa238996a3311c06c514a87",
"proof_c": "8c3f365b53406d22f6bc2003236c396300000000000000000000000000000000",
"proof_s": "15e89038665483b69291f9a67b8b2ad368d4d4d43cf78f04db136a19ad0c3502",
"flags": "00"
},
{
"comment": "ed25519-sha512-tai vector-1",
"sk": "fc4722b3efeadcfa8b437f6e34f71c50a240bd2e66b958c5c17519cc9d936906",
"pk": "bf512469e7f9b766bf5c75e47e84fda3ec887bd24d79b9165c19e01a88fe5ff2",
"alpha": "0a",
"ad": "",
"h": "31e761a08859ec02432a3ad7296ac74a570fe1ee32557358675b85e1ad4fb2a5",
"gamma": "a1e8caa6135c672ad3c6b3173a601e47ec0ac0d748a777a96c136631ea140d97",
"beta": "dc69e5d361dad693a5e51bd9eeb7ba29b21cf55ec5f9e94a8aae0ce34aad27e97efd3acb496d0a0d9f9db352234f8d658d7601dffdf8d6cda08b51bf3d45e6e7",
"proof_c": "db9b97d86d5a727fd85f870c2b317ded00000000000000000000000000000000",
"proof_s": "b74c85ecf8a12841762e1e5dd370bbbdd671501b376bbe7847ff3789190cd90d",
"flags": "00"
},
{
"comment": "ed25519-sha512-tai vector-2",
"sk": "3ed3f4d0fadb42cb77d42a7ea57def2bad464bd1ae0c896dd077c04358415c04",
"pk": "a9a4b61b52db164253147e0c5bd20852d7ab4763e996d0117febccbc7a1abbd6",
"alpha": "",
"ad": "0b8c",
"h": "95799d361fef9b2c236e6fffe73002d42337dfd730d68a4c912f0b9c111a3908",
"gamma": "fba8d885ff14f2789904dd5ac03165d1abd53653c30863c90cfdf77a965c0e5b",
"beta": "197c02c1b7e9b04af15542c72319c19f472ad847aceff3b995bd855131c5857e431e75c09b4843ebcfa1edff79f7c02c1906a7a4ba6a33c9620a51abf190cb4a",
"proof_c": "730630d6d563a4bfb0375b7d3fb9999300000000000000000000000000000000",
"proof_s": "4f8370f6cc829ae7798e1b52911ea23074e17605ac268ac9976a6586d801a10c",
"flags": "00"
},
{
"comment": "ed25519-sha512-tai vector-3",
"sk": "a665fa5af45ab71a60a6b667bc995423d5ee43197a5fd93b16f761cf0bdf0407",
"pk": "0b33325148327641856fde36d56aaf2cb1e4959824bb0916517160d402973bc5",
"alpha": "73616d706c65",
"ad": "",
"h": "3dd1f2d4fd1667ab6b1cf5ec42069ff3bccf6e30391df5f9ded9cadd517a0672",
"gamma": "c818c884884ed9b93c2ff1fe07e4867a35667d75b89a4319b6c0bac5a379217c",
"beta": "7fdc2481d78a41b8abb4c3e88d80a59dde855191eaf8dee40dc18255a798a4b4839a5187f0df2f89cdf5aa5c5f804b4bd3bcd68d8201514eda62b1273b329788",
"proof_c": "15bde9c06cc527c4aee32389a294ff7e00000000000000000000000000000000",
"proof_s": "b7a3677db31e2ee182043056a343b374b66143cb00331edcaf02b39208611803",
"flags": "00"
},
{
"comment": "ed25519-sha512-tai vector-4",
"sk": "9a150e5caf622cc949d95af8980d458b551ab394d52ba49759433b4d04d9f703",
"pk": "cf2d35428c1e329dfbd5ce3a6aafd8cffe31c6a0685471f59f5cddec0725483a",
"alpha": "42616e646572736e6174636820766563746f72",
"ad": "",
"h": "f44ee6fdbb3f94a54eb150c1b08dae7b4933cf465a51a9a6954fa154474e86ed",
"gamma": "6d36d2f3bf3420825685e2bc61851e93e070d5db3fc8b44649d101a9c2032bcc",
"beta": "eb80bcd497bb9f5368bf29c09b9e9b2d1ecefc39fc79320464384f58f778bbbb37aedd85bdf3816a59373cf3fdbba7104b071bfe6cc8935a03b51a75c43a69bd",
"proof_c": "2664153d7e741dfae51d7ac00e63b08100000000000000000000000000000000",
"proof_s": "67e39ee4ca83cbaa342286a5e5bd3cabd698acf270f4b10f6ffeae854db9c208",
"flags": "00"
},
{
"comment": "ed25519-sha512-tai vector-5",
"sk": "03cb98147455ef9db48d9f1ca758d8047f43ed4320909800d849522444b52502",
"pk": "465a022ab19f37d3586489ae08808b23d39844fd321735d6573c089b12202d1a",
"alpha": "42616e646572736e6174636820766563746f72",
"ad": "73616d706c65",
"h": "26f6798e7fbe69080f3d8cac490c9c2eb494a3de4a3ee775102d730ae9274ddc",
"gamma": "5bd7d2261b1f8d497d23602bb1dfb879b9c1eb35c870fd19e4bf6ca4ee94a8bc",
"beta": "8826d659382e14fa480a994b6d9da2ffc51dc77307b82eaa3be1db6f785f24e1a5ed63daf21248cd4fe3cd687ae063075fea36e12b805f42fb9ee5a479105090",
"proof_c": "8eb628ad90d3b8b6d31f702ad9e1381b00000000000000000000000000000000",
"proof_s": "b4e3adf996742217f0ccc6e8d61fc300395425d7a4a5fc8782ac7694ea8dd905",
"flags": "00"
}
]
39 changes: 31 additions & 8 deletions src/suites/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,20 @@
use crate::{pedersen::PedersenSuite, *};
use ark_ff::MontFp;

#[derive(Copy, Clone)]
pub struct Ed25519Sha512;
#[derive(Debug, Copy, Clone)]
pub struct Ed25519Sha512Tai;

suite_types!(Ed25519Sha512);
suite_types!(Ed25519Sha512Tai);

#[cfg(test)]
suite_tests!(Ed25519Sha512);

impl Suite for Ed25519Sha512 {
impl Suite for Ed25519Sha512Tai {
const SUITE_ID: &'static [u8] = b"ed25519-sha512-tai";
const CHALLENGE_LEN: usize = 16;

type Affine = ark_ed25519::EdwardsAffine;
type Hasher = sha2::Sha512;
}

impl PedersenSuite for Ed25519Sha512 {
impl PedersenSuite for Ed25519Sha512Tai {
const BLINDING_BASE: AffinePoint = {
const X: BaseField =
MontFp!("1181072390894490040170698195029164902368238760122173135634802939739986120753");
Expand All @@ -77,3 +74,29 @@ impl PedersenSuite for Ed25519Sha512 {
AffinePoint::new_unchecked(X, Y)
};
}

#[cfg(test)]
suite_tests!(Ed25519Sha512Tai);

#[cfg(test)]
mod test_vectors {
use super::*;

type S = Ed25519Sha512Tai;

const TEST_VECTORS_FILE: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/data/ed25519_sha512_tai_vectors.json"
);

#[test]
#[ignore = "test vectors generator"]
fn test_vectors_generate() {
testing::test_vectors_generate::<S>(TEST_VECTORS_FILE);
}

#[test]
fn test_vectors_process() {
testing::test_vectors_process::<S>(TEST_VECTORS_FILE);
}
}

0 comments on commit b72900d

Please sign in to comment.