|  | 
|  | 1 | +import * as Request from './request.js'; | 
|  | 2 | +import { AccountCredDID, GivenContext, IdCredentialStatement, IdentityProviderDID } from './shared.js'; | 
|  | 3 | + | 
|  | 4 | +// Context for the proof part. | 
|  | 5 | +// NOTE: renamed from FilledContextInformation | 
|  | 6 | +export type Context = { | 
|  | 7 | +    type: 'ConcordiumContextInformationV1'; | 
|  | 8 | +    given: GivenContext[]; | 
|  | 9 | +    requested: GivenContext[]; | 
|  | 10 | +}; | 
|  | 11 | + | 
|  | 12 | +// Fails if not given the full amount of requested context. | 
|  | 13 | +export function createContext(context: Request.Context, requestedContextData: GivenContext[]): Context { | 
|  | 14 | +    throw new Error('not implemented'); | 
|  | 15 | +} | 
|  | 16 | + | 
|  | 17 | +type ConcordiumZKProofV4 = { | 
|  | 18 | +    type: 'ConcordiumZKProofV4'; | 
|  | 19 | +    createdAt: Date; // Explicit type, JSON: ISO format | 
|  | 20 | +    proofValue: Uint8Array; // Explicit type, JSON: hex encoding of proof + aux data | 
|  | 21 | +}; | 
|  | 22 | + | 
|  | 23 | +type WeakLinkingProofV1 = { | 
|  | 24 | +    type: 'ConcordiumWeakLinkingProofV1'; | 
|  | 25 | +    created: Date; | 
|  | 26 | +    proofValue: Uint8Array[]; | 
|  | 27 | +}; | 
|  | 28 | + | 
|  | 29 | +type IDCredPubEncryption = Uint8Array; // right?? | 
|  | 30 | + | 
|  | 31 | +type IDBasedCredential = { | 
|  | 32 | +    type: ['VerifiableCredential', 'ConcordiumVerifiableCredentialV1', 'ConcordiumIDBasedCredential']; | 
|  | 33 | +    // The person this statement is about | 
|  | 34 | +    credentialSubject: { | 
|  | 35 | +        // The identity disclosure information also acts as ephemeral ID | 
|  | 36 | +        id: IDCredPubEncryption; | 
|  | 37 | +        // Statements (should match request) | 
|  | 38 | +        statements: IdCredentialStatement[]; | 
|  | 39 | +    }; | 
|  | 40 | +    // The zero-knowledge proof for attestation. | 
|  | 41 | +    proof: ConcordiumZKProofV4; | 
|  | 42 | +    // Issuer of the orignal ID credential | 
|  | 43 | +    issuer: IdentityProviderDID; | 
|  | 44 | +}; | 
|  | 45 | + | 
|  | 46 | +type AccountBasedCredential = { | 
|  | 47 | +    type: ['VerifiableCredential', 'ConcordiumVerifiableCredentialV1', 'ConcordiumAccountBaseCredential']; | 
|  | 48 | +    // The person this statement is about | 
|  | 49 | +    credentialSubject: { | 
|  | 50 | +        // The id is the account credential identifier | 
|  | 51 | +        id: AccountCredDID; | 
|  | 52 | +        // Statements (should match request) | 
|  | 53 | +        statements: IdCredentialStatement[]; | 
|  | 54 | +    }; | 
|  | 55 | +    // The zero-knowledge proof for attestation. | 
|  | 56 | +    proof: ConcordiumZKProofV4; | 
|  | 57 | +    // The issuer of the ID credential used to open the account credential. | 
|  | 58 | +    issuer: IdentityProviderDID; | 
|  | 59 | +}; | 
|  | 60 | + | 
|  | 61 | +type VerifiableCredential = IDBasedCredential | AccountBasedCredential; | 
|  | 62 | + | 
|  | 63 | +// TODO: Should match the w3c spec for a verifiable presentation | 
|  | 64 | +type JSON = void; | 
|  | 65 | + | 
|  | 66 | +class VerifiablePresentationV1 { | 
|  | 67 | +    type = ['VerifiablePresentation', 'ConcordiumVerifiablePresentationV1']; | 
|  | 68 | + | 
|  | 69 | +    constructor( | 
|  | 70 | +        public readonly presentationContext: Context, | 
|  | 71 | +        public readonly verifiableCredential: VerifiableCredential[], | 
|  | 72 | +        public readonly proof?: WeakLinkingProofV1 | 
|  | 73 | +    ) {} | 
|  | 74 | + | 
|  | 75 | +    public toJSON(): JSON {} | 
|  | 76 | +} | 
|  | 77 | + | 
|  | 78 | +export type Type = VerifiablePresentationV1; | 
|  | 79 | + | 
|  | 80 | +// TODO: what's the input here? | 
|  | 81 | +export function create(request: Request.Type): VerifiablePresentationV1 { | 
|  | 82 | +    // NOTE: this calls into concordium-base bindings to generate the proof | 
|  | 83 | +    throw new Error('not implemented'); | 
|  | 84 | +} | 
|  | 85 | + | 
|  | 86 | +export function fromJSON(json: JSON): VerifiablePresentationV1 { | 
|  | 87 | +    throw new Error('not implemented'); | 
|  | 88 | +} | 
|  | 89 | + | 
|  | 90 | +// TODO: what's the input/output here? | 
|  | 91 | +export function verify(request: Request.Type): unknown { | 
|  | 92 | +    // NOTE: this calls into concordium-base bindings to verify the proof | 
|  | 93 | +    throw new Error('not implemented'); | 
|  | 94 | +} | 
0 commit comments