-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from Concordium/web3Proofs
Web3Id proofs
- Loading branch information
Showing
26 changed files
with
1,738 additions
and
254 deletions.
There are no files selected for viewing
Submodule concordium-base
updated
58 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
export interface StatementBuilder<ValueType, AttributeType> { | ||
addRange( | ||
attribute: AttributeType, | ||
lower: ValueType, | ||
upper: ValueType | ||
): this; | ||
|
||
addMembership(attribute: AttributeType, set: ValueType[]): this; | ||
|
||
addNonMembership(attribute: AttributeType, set: ValueType[]): this; | ||
revealAttribute(attribute: AttributeType): this; | ||
getStatement(): GenericAtomicStatement<AttributeType, ValueType>[]; | ||
} | ||
|
||
export const MIN_DATE = '18000101'; | ||
export const MAX_DATE = '99990101'; | ||
export const EU_MEMBERS = [ | ||
'AT', | ||
'BE', | ||
'BG', | ||
'CY', | ||
'CZ', | ||
'DK', | ||
'EE', | ||
'FI', | ||
'FR', | ||
'DE', | ||
'GR', | ||
'HU', | ||
'IE', | ||
'IT', | ||
'LV', | ||
'LT', | ||
'LU', | ||
'MT', | ||
'NL', | ||
'PL', | ||
'PT', | ||
'RO', | ||
'SK', | ||
'SI', | ||
'ES', | ||
'SE', | ||
'HR', | ||
]; | ||
|
||
export enum StatementTypes { | ||
RevealAttribute = 'RevealAttribute', | ||
AttributeInSet = 'AttributeInSet', | ||
AttributeNotInSet = 'AttributeNotInSet', | ||
AttributeInRange = 'AttributeInRange', | ||
} | ||
|
||
type LaxStringEnum<E extends string> = `${E}`; | ||
|
||
export type GenericRevealStatement<TagType> = { | ||
type: LaxStringEnum<StatementTypes.RevealAttribute>; | ||
attributeTag: TagType; | ||
}; | ||
|
||
export type GenericMembershipStatement<TagType, ValueType> = { | ||
type: LaxStringEnum<StatementTypes.AttributeInSet>; | ||
attributeTag: TagType; | ||
set: ValueType[]; | ||
}; | ||
|
||
export type GenericNonMembershipStatement<TagType, ValueType> = { | ||
type: LaxStringEnum<StatementTypes.AttributeNotInSet>; | ||
attributeTag: TagType; | ||
set: ValueType[]; | ||
}; | ||
|
||
export type GenericRangeStatement<TagType, ValueType> = { | ||
type: LaxStringEnum<StatementTypes.AttributeInRange>; | ||
attributeTag: TagType; | ||
lower: ValueType; | ||
upper: ValueType; | ||
}; | ||
|
||
export type GenericAtomicStatement<TagType, ValueType> = | ||
| GenericRevealStatement<TagType> | ||
| GenericMembershipStatement<TagType, ValueType> | ||
| GenericNonMembershipStatement<TagType, ValueType> | ||
| GenericRangeStatement<TagType, ValueType>; | ||
|
||
export type RevealProof<ValueType> = { | ||
type: StatementTypes.RevealAttribute; | ||
proof: string; | ||
attribute: ValueType; | ||
}; | ||
|
||
// Type for proofs that do not have additional fields | ||
export type GenericAtomicProof = { | ||
type: Exclude<StatementTypes, StatementTypes.RevealAttribute>; | ||
proof: string; | ||
}; | ||
|
||
export type AtomicProof<ValueType> = | ||
| RevealProof<ValueType> | ||
| GenericAtomicProof; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as wasm from '@concordium/rust-bindings'; | ||
import { stringify } from 'json-bigint'; | ||
import { ContractAddress, CryptographicParameters } from './types'; | ||
|
||
export type VerifyWeb3IdCredentialSignatureInput = { | ||
globalContext: CryptographicParameters; | ||
signature: string; | ||
values: Record<string, string | bigint>; | ||
randomness: Record<string, string>; | ||
holder: string; | ||
issuerPublicKey: string; | ||
issuerContract: ContractAddress; | ||
}; | ||
|
||
/** | ||
* Verifies that the given signature is correct for the given values/randomness/holder/issuerPublicKey/issuerContract | ||
*/ | ||
export function verifyWeb3IdCredentialSignature( | ||
input: VerifyWeb3IdCredentialSignatureInput | ||
): boolean { | ||
// Use json-bigint stringify to ensure we can handle bigints | ||
return wasm.verifyWeb3IdCredentialSignature(stringify(input)); | ||
} |
Oops, something went wrong.