hyli-noir 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Check Secret Noir
2
+
3
+ This is a demonstration project that shows how to implement a secret checking system using Noir (a Domain Specific Language for SNARK proving systems) with a web frontend.
4
+
5
+ ## Project Structure
6
+
7
+ - `/contract` - Contains the Noir smart contract code
8
+ - `src/main.nr` - The main Noir contract implementing the secret checking logic
9
+ - `/frontend` - Web interface implementation
10
+
11
+ ## Features
12
+
13
+ - Zero-knowledge proof based secret verification
14
+ - Web interface for submitting identity and password
15
+ - Real-time proof verification display
16
+ - Secure password handling through zero-knowledge proofs, settling on Hyle network.
17
+
18
+ ## Setup and Running
19
+
20
+ 1. Install dependencies:
21
+ ```bash
22
+ # In the frontend directory
23
+ bun install
24
+ ```
25
+
26
+ 2. Run the frontend development server:
27
+ ```bash
28
+ # In the frontend directory
29
+ bun run dev
30
+ ```
31
+
32
+ ## Security
33
+
34
+ This example demonstrates zero-knowledge proof concepts for password verification. The password is never directly exposed in the verification process, enhancing security through cryptographic proofs.
35
+
@@ -0,0 +1,44 @@
1
+ import { CompiledCircuit } from "@noir-lang/types";
2
+ import { Blob, ProofTransaction, NodeApiHttpClient } from "hyli";
3
+ /**
4
+ * Builds a blob transaction containing a secret derived from an identity and password.
5
+ * The secret is constructed by:
6
+ * 1. Hashing the password in order to have a fixed-size secret
7
+ * 2. Concatenating the padded identity (to 64 chars) with ':' and the hashed password
8
+ * 3. Hashing this combined value
9
+ *
10
+ * @param identity - The user's identity string
11
+ * @param password - The user's password string
12
+ * @returns A Promise resolving to a BlobTransaction containing the hashed secret
13
+ */
14
+ export declare const build_blob: (identity: string, password: string) => Promise<Blob>;
15
+ /**
16
+ * Builds a proof transaction by generating a zero-knowledge proof for checking a secret.
17
+ * The proof demonstrates knowledge of a password that, when combined with an identity and hashed,
18
+ * matches a stored hash value. The process involves:
19
+ * 1. Hashing the password and combining it with the identity
20
+ * 2. Generating a witness and proof using the UltraHonk backend
21
+ * 3. Reconstructing and formatting the proof for the transaction
22
+ *
23
+ * @param identity - The user's identity string
24
+ * @param password - The user's password string
25
+ * @param tx_hash - The blob transaction hash string
26
+ * @param circuit - The compiled Noir circuit (defaults to the check_secret circuit)
27
+ * @returns A Promise resolving to a ProofTransaction containing the generated proof
28
+ */
29
+ export declare const build_proof_transaction: (identity: string, password: string, tx_hash: string, blob_index: number, tx_blob_count: number, circuit?: CompiledCircuit) => Promise<ProofTransaction>;
30
+ /**
31
+ * Registers the Noir contract with the node if it is not already registered.
32
+ * The contract is identified by its name "check_secret".
33
+ * If the contract is not found, it registers the contract using the provided circuit.
34
+ *
35
+ * @param node - The NodeApiHttpClient instance to interact with the NodeApiHttpClient
36
+ * @param circuit - The compiled Noir circuit (defaults to the check_secret circuit)
37
+ * @returns A Promise that resolves when the contract is registered
38
+ */
39
+ export declare const register_contract: (node: NodeApiHttpClient, circuit?: CompiledCircuit) => Promise<void>;
40
+ export declare const assert: (condition: boolean, message: string) => void;
41
+ export declare const sha256: (data: Uint8Array) => Promise<Uint8Array>;
42
+ export declare const stringToBytes: (input: string) => Uint8Array;
43
+ export declare const encodeToHex: (data: Uint8Array) => string;
44
+ export declare function flattenFieldsAsArray(fields: string[]): Uint8Array;