Update tlsn-js to use tlsn alpha4 (#17)

* build: Update tlsn dependency to v0.1.0-alpha.4

* chore: resolve lint warnings
This commit is contained in:
Hendrik Eeckhaut
2024-02-15 07:06:50 +01:00
committed by GitHub
parent 079f1a314c
commit afe9e48740
5 changed files with 17 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "tlsn-js",
"version": "v0.1.0-alpha.3",
"version": "v0.1.0-alpha.4",
"description": "",
"repository": "https://github.com/tlsnotary/tlsn-js",
"main": "build/index.js",
@@ -22,6 +22,7 @@
"watch:dev": "webpack --config webpack.web.dev.config.js --watch",
"predev": "sh utils/check-wasm.sh",
"dev": "concurrently npm:watch:dev npm:serve:dev",
"lint:wasm": "cd wasm/prover; cargo clippy --target wasm32-unknown-unknown",
"lint:eslint": "eslint . --fix",
"lint:tsc": "tsc --noEmit",
"lint": "concurrently npm:lint:tsc npm:lint:eslint",
@@ -70,4 +71,4 @@
"engines": {
"node": ">= 16.20.2"
}
}
}

View File

@@ -1,5 +1,4 @@
import { prove, verify } from '../src';
import simple_proof_redacted from './assets/simple_proof_redacted.json';
(async function () {
try {

View File

@@ -36,13 +36,12 @@ ring = {version = "0.17", features = ["wasm32_unknown_unknown_js"]}
# time crate: https://crates.io/crates/time
# NOTE: It is required, otherwise "time not implemented on this platform" error happens right after "!@# 2".
# Probably due to tokio's time feature is used in tlsn-prover?
# Temporarily fixed to 0.3.31 as a workaround for https://github.com/time-rs/time/issues/652
time = {version = "=0.3.31", features = ["wasm-bindgen"]}
time = {version = "0.3.34", features = ["wasm-bindgen"]}
# Used to calculate elapsed time.
web-time = "0.2"
web-time = "1.0"
tlsn-core = {git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.3", package = "tlsn-core"}
tlsn-prover = {git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.3", package = "tlsn-prover", features = [
tlsn-core = {git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.4", package = "tlsn-core"}
tlsn-prover = {git = "https://github.com/tlsnotary/tlsn.git", tag = "v0.1.0-alpha.4", package = "tlsn-prover", features = [
"tracing",
]}

View File

@@ -193,6 +193,8 @@ pub async fn prover(
.await
.map_err(|e| JsValue::from_str(&format!("Could not set up prover: {:?}", e)))?;
log!("!@# 2");
// Bind the Prover to the server connection.
// The returned `mpc_tls_connection` is an MPC TLS connection to the Server: all data written
// to/read from it will be encrypted/decrypted using MPC with the Notary.
@@ -350,7 +352,7 @@ pub async fn prover(
let sent_pub_commitment_ids = sent_public_ranges
.iter()
.map(|range| {
builder.commit_sent(range.clone()).map_err(|e| {
builder.commit_sent(range).map_err(|e| {
JsValue::from_str(&format!("Error committing sent pub range: {:?}", e))
})
})
@@ -358,7 +360,7 @@ pub async fn prover(
sent_private_ranges.iter().try_for_each(|range| {
builder
.commit_sent(range.clone())
.commit_sent(range)
.map_err(|e| {
JsValue::from_str(&format!("Error committing sent private range: {:?}", e))
})
@@ -368,7 +370,7 @@ pub async fn prover(
let recv_pub_commitment_ids = recv_public_ranges
.iter()
.map(|range| {
builder.commit_recv(range.clone()).map_err(|e| {
builder.commit_recv(range).map_err(|e| {
JsValue::from_str(&format!("Error committing recv public ranges: {:?}", e))
})
})
@@ -376,7 +378,7 @@ pub async fn prover(
recv_private_ranges.iter().try_for_each(|range| {
builder
.commit_sent(range.clone())
.commit_sent(range)
.map_err(|e| {
JsValue::from_str(&format!("Error committing recv private range: {:?}", e))
})
@@ -402,7 +404,7 @@ pub async fn prover(
.chain(recv_pub_commitment_ids.iter())
.try_for_each(|id| {
proof_builder
.reveal(*id)
.reveal_by_id(*id)
.map_err(|e| JsValue::from_str(&format!("Could not reveal commitment: {:?}", e)))
.map(|_| ())
})?;
@@ -453,7 +455,7 @@ pub async fn verify(proof: &str, notary_pubkey_str: &str) -> Result<String, JsVa
// The session header that was signed by the Notary is a succinct commitment to the TLS transcript.
header,
// This is the server name, checked against the certificate chain shared in the TLS handshake.
server_name,
session_info,
..
} = session;
@@ -474,7 +476,7 @@ pub async fn verify(proof: &str, notary_pubkey_str: &str) -> Result<String, JsVa
log!("-------------------------------------------------------------------");
log!(
"Successfully verified that the bytes below came from a session with {:?} at {}.",
server_name,
session_info.server_name,
time
);
log!("Note that the bytes which the Prover chose not to disclose are shown as X.");
@@ -497,7 +499,7 @@ pub async fn verify(proof: &str, notary_pubkey_str: &str) -> Result<String, JsVa
log!("-------------------------------------------------------------------");
let result = VerifyResult {
server_name: String::from(server_name.as_str()),
server_name: String::from(session_info.server_name.as_str()),
time: header.time(),
sent: String::from_utf8(sent.data().to_vec()).map_err(|e| {
JsValue::from_str(&format!("Could not convert sent data to string: {:?}", e))