Skip to content

Refactor Client Class to Follow [finData, request] OPRF Convention #16

Description

@sublimator

Description

The current implementation of the Client class is designed to handle a single request at a time. This design can be surprising/confusing and does not align with the convention used in the OPRF setup, which returns a tuple [finData, request].

Proposed Solution

Two possible ways to approach this refactoring:

  1. Rename Client to TokenRequestContext to better convey the per-request state and update its methods accordingly.
  2. Modify the createTokenRequest method to return a tuple [finData, request] instead of a single TokenRequest object.

It's proposed to refactor the Client class to adhere to the OPRF convention.

export class TokenRequestContext {
    private finData?: {
        pkIssuer: CryptoKey;
        tokenInput: Uint8Array;
        authInput: AuthenticatorInput;
        inv: Uint8Array;
    };

    async createRequest(
        tokChl: TokenChallenge,
        issuerPublicKey: Uint8Array,
    ): Promise<TokenRequest> {

or

interface Client2State {
    authInput: AuthenticatorInput;
    finData: FinalizeData;
}

export class Client2 {
    vClient: Client<ModeVoprf>;

    constructor(private issuerPublicKey: Uint8Array) {
        this.vClient = MODE.makeClient(issuerPublicKey);
    }

    async createTokenRequest(
        tokChl: TokenChallenge,
    ): Promise<[finData: Client2State, request: TokenRequest2]> {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions