Skip to content
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

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

Open
sublimator opened this issue Oct 15, 2023 · 0 comments
Open

Comments

@sublimator
Copy link

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]> {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant