1.7.4 • Published 9 months ago

c1ph3r_c01n v1.7.4

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
9 months ago

c1ph3r_c01n

A TypeScript package for cryptographic proof generation and verification with settlement support.

Installation

npm install c1ph3r_c01n

Basic Usage

import { C1ph3rSDK } from 'c1ph3r_c01n';

// Initialize SDK with optional settlement API URL
const apiKey = 'secret-verifier';
const requireHmacAuth = true;
const cipher = new C1ph3rSDK('https://settlement-api.example.com', apiKey, requireHmacAuth);

// Example private key (for demonstration only)
const privateKey = '0xb06bbba13c2ce93621525d166e286f212de43f2fb87853aa19025751932d9cbd';

async function example() {
    // Start new authentication session
    const auth = await cipher.startNewAuth(
        privateKey,
        'myPassword123',  // password (4-100 chars)
        'RDUL'           // sequence (exactly 4 chars: U, D, L, R) for RGBY so U -> Red, D -> Yellow, L -> Blue, R -> Green
    );

    // Solve rounds one by one
    cipher.solveCurrentRound('U');
    const nextRound = cipher.getCurrentRound();
    cipher.solveCurrentRound('D');
    // ... continue for all rounds
    // if it's not the last round then solveCurrentRound will return the next round, so the response will be like this 
    {
        success: true, // true means that solutions was accepted (doesn't mean it's correct or wrong)
        verificationResponse: null // this means that it's not the last round
    }

    // if it's the last round then solveCurrentRound will return the verificationResponse, so the response will be like this 
    {
        success: true, // true means that solutions was accepted (doesn't mean it's correct or wrong)
        verificationResponse: Promise<VerificationResponse> // this is the response from the verifier, so it will contain if the rwp is correct or not (verificationResponse.response.rwp_result)
    }
    
    // Check settlement status if using aRPC
    const settlementStatus = await verification.settlementPromise;
}

API Reference

C1ph3rSDK

Constructor

constructor(arpcSettlementApiUrl?: string)
  • arpcSettlementApiUrl: Optional URL for settlement verification
  • Throws: Error if URL is invalid

Methods

startNewAuth(privateKey: string, password?: string, directions?: string)

Initializes a new proof session.

Parameters:

  • privateKey: Ethereum private key (hex string with '0x' prefix)
  • password: Optional if previously set, 4-100 characters
  • directions: Optional if previously set, exactly 4 characters (U, D, L, R)

Returns: Promise<{ proverState: any, currentRound: number, colorAssignments: any }>

Throws:

  • If authentication already in progress
  • If password/directions not provided and no stored data
  • If inputs are invalid
  • If prover initialization fails
solveCurrentRound(solution: string)

Submits solution for current round.

Parameters:

  • solution: Single character (U, D, L, R)

Returns: { success: boolean, message?: string, verificationResponse: Promise | null }

Throws:

  • If no authentication in progress
  • If invalid solution
  • If no more rounds available
verifyAuth(solution: string)

Verifies complete authentication attempt.

Parameters:

  • solution: String of U, D, L, R characters

Returns: Promise<{ verificationResult: boolean, responses: any, settlementPromise?: Promise }>

Throws:

  • If invalid solution format
  • If prover state not found
getCurrentRound()

Retrieves current round's color assignments.

Returns: { success: boolean, colorAssignment: any, message?: string }

Throws:

  • If no authentication in progress
getLastSettlementStatus()

Retrieves status of last settlement attempt.

Returns: Promise<SettlementResponse | null>

Data Persistence

  • Browser: Encrypted credentials stored in localStorage
  • Node.js: Must provide credentials each time

Error Handling

The SDK throws descriptive errors for:

  • Invalid inputs
  • Authentication state issues
  • Encryption/decryption failures
  • Network errors
  • Settlement verification failures

Settlement Integration

When initialized with an aRPC settlement API URL:

  • Non-blocking settlement verification
  • Access settlement status via verification.settlementPromise
  • Query last settlement via getLastSettlementStatus()

Performance Benchmarks

  • Authentication: ~6.10s
  • Verification: ~0.08s
  • Settlement: ~4.69s

Version History

1.2.7

  • Added non-blocking aRPC settlement
  • Settlement status accessible via settlementPromise

1.2.6

  • Added blocking aRPC settlement

1.1.5

  • Added localhost development support
  • Improved error handling
  • Added browser storage support
1.7.4

9 months ago

1.7.3

9 months ago

1.7.2

9 months ago

1.7.1

9 months ago

1.7.0

9 months ago

1.6.9

9 months ago

1.6.8

9 months ago

1.6.7

9 months ago

1.6.4

9 months ago

1.4.6

9 months ago

1.6.3

9 months ago

1.4.5

9 months ago

1.6.2

9 months ago

1.4.4

9 months ago

1.6.1

9 months ago

1.6.0

9 months ago

1.5.9

9 months ago

1.5.8

9 months ago

1.5.6

9 months ago

1.5.5

9 months ago

1.5.4

9 months ago

1.5.3

9 months ago

1.5.1

9 months ago

1.5.0

9 months ago

1.4.9

9 months ago

1.6.6

9 months ago

1.4.8

9 months ago

1.6.5

9 months ago

1.4.7

9 months ago

1.3.7

10 months ago

1.2.8

10 months ago

1.3.6

10 months ago

1.2.7

10 months ago

1.3.5

10 months ago

1.2.6

10 months ago

1.4.3

9 months ago

1.3.4

10 months ago

1.2.5

10 months ago

1.4.2

9 months ago

1.3.3

10 months ago

1.4.1

9 months ago

1.3.2

10 months ago

1.4.0

9 months ago

1.3.1

10 months ago

1.3.0

10 months ago

1.3.9

9 months ago

1.3.8

10 months ago

1.2.9

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.9

10 months ago

1.1.8

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago