Git Product home page Git Product logo

Comments (5)

Therecanbeonlyone1969 avatar Therecanbeonlyone1969 commented on August 30, 2024 1

@biscuitdey also circomlibjs supports EdDSA sigs such as with MimC e.g.

const buildEddsa = require("circomlibjs").buildEddsa;
import * as crypto from "crypto";

const SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
const genRandomBabyJubValue = () => {
  // Prevent modulo bias
  //const lim = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000')
  //const min = (lim - SNARK_FIELD_SIZE) % SNARK_FIELD_SIZE
  const min = BigInt("6350874878119819312338956282401532410528162663560392320966563075034087161851");

  let rand;
  // eslint-disable-next-line no-constant-condition
  while (true) {
    rand = BigInt("0x" + crypto.randomBytes(32).toString("hex"));

    if (rand >= min) {
      break;
    }
  }

  const privKey = rand % SNARK_SCALAR_FIELD;

  return privKey;
};

async function eddsasig() {
    const eddsa = await buildEddsa();
    const plaintext = rand = BigInt("0x" + crypto.randomBytes(32).toString("hex"));
    const F = eddsa.F;
    const issuerPrivKey = genRandomBabyJubValue();
    const issuerPubKey = eddsa.prv2pub(issuerPrivKey.toString());
    const signature = eddsa.signMiMC(issuerPrivKey.toString(), F.e(plaintext));

    return signature;
    }

from baseline.

biscuitdey avatar biscuitdey commented on August 30, 2024

@Therecanbeonlyone1969 Is there any library you recommend for generating Eddsa signatures? I found the following libraries :

  1. @transmute/ed25519-signature-2018
  2. @digitalcredentials/ed25519-signature-2020
  3. @digitalbazaar/ed25519-signature-2020

from baseline.

Therecanbeonlyone1969 avatar Therecanbeonlyone1969 commented on August 30, 2024

@biscuitdey here you go https://github.com/paulmillr/noble-curves

from baseline.

biscuitdey avatar biscuitdey commented on August 30, 2024

@Therecanbeonlyone1969

@biscuitdey also circomlibjs supports EdDSA sigs such as with MimC e.g.

const buildEddsa = require("circomlibjs").buildEddsa;
import * as crypto from "crypto";

const SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
const genRandomBabyJubValue = () => {
  // Prevent modulo bias
  //const lim = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000')
  //const min = (lim - SNARK_FIELD_SIZE) % SNARK_FIELD_SIZE
  const min = BigInt("6350874878119819312338956282401532410528162663560392320966563075034087161851");

  let rand;
  // eslint-disable-next-line no-constant-condition
  while (true) {
    rand = BigInt("0x" + crypto.randomBytes(32).toString("hex"));

    if (rand >= min) {
      break;
    }
  }

  const privKey = rand % SNARK_SCALAR_FIELD;

  return privKey;
};

async function eddsasig() {
    const eddsa = await buildEddsa();
    const plaintext = rand = BigInt("0x" + crypto.randomBytes(32).toString("hex"));
    const F = eddsa.F;
    const issuerPrivKey = genRandomBabyJubValue();
    const issuerPubKey = eddsa.prv2pub(issuerPrivKey.toString());
    const signature = eddsa.signMiMC(issuerPrivKey.toString(), F.e(plaintext));

    return signature;
    }

I am using this same library

from baseline.

ognjenkurtic avatar ognjenkurtic commented on August 30, 2024

Currently blocked by #765

from baseline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.