aldenml / ecc Goto Github PK
View Code? Open in Web Editor NEWelliptic-curve cryptography
License: MIT License
elliptic-curve cryptography
License: MIT License
Hello,
I'm trying to achieve the following scheme
C
encrypt a message with A
public key and send it to the Proxy
A
creates a re-encryption key that the proxy can use to share data with B
I managed to achieve it only if the re-encryption is signed by C
pre_schema1_ReKeyGen(keysA.sk, keysB.pk, signingC);
This is not very practical in the following situation
A
has a data repository, managed by Proxy
anyone can contribute to this data repository by positing messages encrypted with A.pk
A
select who can read these data by creating reEncKey for each recipient.
In this situation it would mean that A
would have to create n reEncKeys for each Contributor/Recipient pair.
Do I miss a point that would allow to have only one reEncKey per recipient ?
Here is a sample working code
let ecc;
async function main() {
// client A setup public/private keys and signing keys
const keysA = await ecc.pre_schema1_KeyGen();
const signingA = await ecc.pre_schema1_SigningKeyGen();
// client B setup public/private keys (signing keys are not used here)
const keysB = await ecc.pre_schema1_KeyGen();
// proxy server setup signing keys
const signingProxy = await ecc.pre_schema1_SigningKeyGen();
// client C is the origin encrypting party
const signingC = await ecc.pre_schema1_SigningKeyGen();
// client C select a plaintext message
const message = await ecc.pre_schema1_MessageGen();
const messageS = uintArrayToString(message);
// client C encrypts the message with A key
const ciphertextLevel1 = await ecc.pre_schema1_Encrypt(
message,
keysA.pk,
signingC);
// client A is able to decrypt ciphertextLevel1
const messageDecrypted1 = await ecc.pre_schema1_DecryptLevel1(
ciphertextLevel1,
keysA.sk,
signingC.spk
);
console.log(' Message decrypted == message ', (messageS == uintArrayToString(messageDecrypted1)));
// client A allows client B to see the encrypted
// client A creates a re-encryption key that the proxy can use
// to re-encrypt the ciphertext (ciphertextLevel1) in order for
// client B be able to recover the original message
const reEncKey = await ecc.pre_schema1_ReKeyGen(
keysA.sk,
keysB.pk,
signingC // ⚠️ HERE I WOULD LIKE TO AVOID USING `C` signing Key
);
// the proxy re-encrypt the ciphertext ciphertextLevel1 with such
// a key that allows client B to recover the original message
const ciphertextLevel2 = await ecc.pre_schema1_ReEncrypt(
ciphertextLevel1,
reEncKey,
signingC.spk, // ⚠️ HERE I WOULD LIKE TO AVOID USING `C` signing Key
keysB.pk,
signingProxy
);
// client B is able to decrypt ciphertextLevel2 and the result
// is the original plaintext message
const messageDecrypted2 = await ecc.pre_schema1_DecryptLevel2(
ciphertextLevel2,
keysB.sk, signingProxy.spk
);
// now both client A and client B share the same plaintext message
// messageDecrypted is equal to message
console.log(' Message recrypted/decrypted == message ', (messageS == uintArrayToString(messageDecrypted2)));
}
function uintArrayToString(u8) {
return Buffer.from(u8).toString('base64');
}
function stringToUintArray(b64) {
return new Uint8Array(Buffer.from(b64, 'base64'))
}
(async () => {
ecc = await import('@aldenml/ecc');
await main();
})();
Tried to get your Frost implementation to work, but failed with "memory access out of bounds"
I observed that under:
https://github.com/aldenml/ecc/blob/master/bindings/js/libecc-post.js
Module.ecc_frost_ristretto255_sha512_secret_share_shard_with_coefficients = (
const ptr_points = mput(points, n*ecc_frost_ristretto255_sha512_SCALARSIZE);
Shouldn't this be?
const ptr_points = mput(points, n*ecc_frost_ristretto255_sha512_POINTSIZE);
Can we please add references to the implementation of OPAQUE in this repo to the list of implementations here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.