-
Notifications
You must be signed in to change notification settings - Fork 76
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
Ethereum Group PCD #290
Ethereum Group PCD #290
Conversation
/** | ||
* The offset that the hex representation of the public key starts at, without the 0x prefix and without the 04 prefix. That's what the zk-circuit expects. | ||
* https://github.com/indutny/elliptic/issues/86 | ||
* https://dev.to/q9/finally-understanding-ethereum-accounts-1kpe | ||
*/ | ||
const hexPubkeyOffset = 2 + 2; | ||
|
||
function AddEthGroupPCDButton() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good chunk of code here is duplicated in EthereumGroupPCD.spec.ts
. I tried to refactor it and put this example code in EthereumGroupPCD.ts
but ran into problems in EthereumGroupPCD.init()
. I'm leaving it like this for your review.
apps/passport-client/components/screens/ProveScreen/GenericProveSection.tsx
Outdated
Show resolved
Hide resolved
const isNode = | ||
typeof process !== "undefined" && | ||
process.versions != null && | ||
process.versions.node != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is kosher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend passing a parameter into the init
function via EthereumGroupPCDInitArgs
called something like proverConfigOverride
, which you set only in the browser, so you don't have to do this isNode
checking in the PCD package.
} else { | ||
addrMembershipConfig = { | ||
circuit: | ||
"https://storage.googleapis.com/personae-proving-keys/membership/addr_membership.circuit", | ||
witnessGenWasm: | ||
"https://storage.googleapis.com/personae-proving-keys/membership/addr_membership.wasm", | ||
}; | ||
|
||
pubkeyMembershipConfig = { | ||
circuit: | ||
"https://storage.googleapis.com/personae-proving-keys/membership/pubkey_membership.circuit", | ||
witnessGenWasm: | ||
"https://storage.googleapis.com/personae-proving-keys/membership/pubkey_membership.wasm", | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning from spartan-ecdsa:
Spartan-ecdsa default config warning:
We recommend using defaultPubkeyMembershipPConfig/defaultPubkeyMembershipVConfig only for testing purposes.
Please host and specify the circuit and witnessGenWasm files on your own server for sovereign control.
Download files: https://github.com/personaelabs/spartan-ecdsa/blob/main/packages/lib/README.md#circuit-downloads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can host these on our server here to avoid this warning
- [`@pcd/ethereum-ownership-pcd`](packages/ethereum-ownership-pcd): a pcd that can be used to claim that a Semaphore identity knows the private key of an ethereum address. | ||
- [`@pcd/ethereum-group-pcd`](packages/ethereum-group-pcd): a pcd that can be used to claim that a Semaphore identity knows the private key of an ethereum address or public key that is part of a merkle group of addresses or public keys, without revealing the specific one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
value: undefined, | ||
userProvided: true, | ||
description: | ||
"The Semaphore Identity which you are signing the message.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The Semaphore Identity which you are signing the message.", | |
"The Semaphore Identity with which you are signing the message.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the message
on first read, it's confusing to understand what 'the message' is. I'd recommend changing the description to something like
"The Semaphore Identity which you are proving owns the given Ethereum address."
}, | ||
groupType: { | ||
argumentType: ArgumentTypeName.String, | ||
value: GroupType.PUBLICKEY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should probably also have a happy path for the address group type
} | ||
|
||
export enum GroupType { | ||
PUBLICKEY = "publickey", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PUBLIC_KEY = "public_key"
@@ -1,18 +1,26 @@ | |||
import { EthereumGroupPCDPackage, GroupType } from "@pcd/ethereum-group-pcd"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how this works on your computer, but I needed to add a dependency on this package in the package.json
of consumer-client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should make an equivalent update to apps/passport-server/src/services/provingService.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in startProvingService
? what about all the other pcds?
addrProver = new MembershipProver(addrMembershipConfig); | ||
pubkeyProver = new MembershipProver(pubkeyMembershipConfig); | ||
addrVerifier = new MembershipVerifier(addrMembershipConfig); | ||
pubkeyVerifier = new MembershipVerifier(pubkeyMembershipConfig); | ||
await Promise.all([ | ||
addrProver.initWasm(), | ||
pubkeyProver.initWasm(), | ||
addrVerifier.initWasm(), | ||
pubkeyVerifier.initWasm(), | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* https://dev.to/q9/finally-understanding-ethereum-accounts-1kpe | ||
*/ | ||
export function getRawPubKeyBuffer(pubKey: string): Buffer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
} | ||
|
||
if ( | ||
[GroupType.ADDRESS, GroupType.PUBLICKEY].includes(args.groupType as any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[GroupType.ADDRESS, GroupType.PUBLICKEY].includes(args.groupType as any) | |
![GroupType.ADDRESS, GroupType.PUBLICKEY].includes(args.groupType as any) |
you should run all your code :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah.. it was a double error. Missing the !
and missing the .value
, which led to tests passing.
) | ||
); | ||
parsed.claim.publicInput = publicInput; | ||
return parsed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue with this parse
function is that it's not invoking the constructor of EthereumGroupPCD
, but creating an object that conforms to its type signature. Not a huge deal right now but feels kind of wrong. Checking the way I do this in other packages and it seems that this is a pervasive error. Here's an issue to fix at some point later. #308
newEthGroupPCD.claim.publicInput.circuitPubInput.Uy = | ||
newEthGroupPCD.claim.publicInput.circuitPubInput.Uy - BigInt(1); | ||
|
||
assert(await EthereumGroupPCDPackage.verify(newEthGroupPCD)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
assert(await EthereumGroupPCDPackage.verify(ethGroupPCD)); | ||
}); | ||
|
||
it("should work with address (slow ~40s)", async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sheesh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! last thing left is to resolve the yarn.lock conflicts
Onboarding local dev fixes Fix passport-server:dev concurrently concurrently Ethereum Group PCD Add test more test tests progress Ethereum Address Ownership example in add-pcd.tsx small fix switch to merkleproof eth group pcd in add-pcd smol fix small rename Fix ethereum ownership tests and ethereum group ownership tests remove useNativeBigInt address PR comments address pr comments
Subsumes #287