Skip to content

Commit 1faec83

Browse files
adithyaakrishnarichardliang
authored andcommitted
Update .gitlab-ci.yml
Update .env.sample Delete .env.test add hash option fix pqueue for extension public rc4 fix merge conflicts bump
1 parent e4125a6 commit 1faec83

File tree

8 files changed

+67
-38
lines changed

8 files changed

+67
-38
lines changed

.env.sample

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
# Override the default port for the attestor to run on
22
PORT=
3+
34
# ETH private key. This could be the private key of some other
45
# signature algorithm too. However, at the moment -- only ETH
56
# is supported.
7+
68
PRIVATE_KEY=
9+
710
# Provide a https proxy URL to allow for the creation of geo-specified
811
# tunnels. The attestor will replace {{geolocation}} in the URL
912
# with the geolocation it needs to connect to. geolocation is a 2-letter
1013
# ISO code
14+
1115
HTTPS_PROXY_URL=
16+
1217
# Variables for the Elastic APM
18+
1319
ELASTIC_APM_SERVER_URL=
1420
ELASTIC_APM_SECRET_TOKEN=
21+
1522
# Fraction of requests to be sampled & sent to the Elastic APM
23+
1624
ELASTIC_APM_SAMPLE_RATE=
1725
# Set the log level for the attestor.
1826
# Possible values are: debug, info, warn, error
27+
1928
LOG_LEVEL=
2029
# Number of concurrent ZK proofs to generate
2130
# Default is 10
31+
2232
ZK_CONCURRENCY=
2333
# Chain ID for where the AVS operator is deployed. Only required for
2434
# when registering the operator on the AVS.
@@ -31,4 +41,4 @@ CHAIN_ID=
3141
RECLAIM_PUBLIC_URL=
3242
# should the attestor pay the claim requests
3343
# set to "1" to enable
34-
ACCEPT_CLAIM_PAYMENT_REQUESTS=
44+
ACCEPT_CLAIM_PAYMENT_REQUESTS=

.env.test

-6
This file was deleted.

package-lock.json

+30-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@reclaimprotocol/attestor-core",
3-
"version": "3.0.6",
4-
"description": "",
2+
"name": "@zkp2p/reclaim-witness-sdk",
3+
"version": "0.0.2-rc4",
4+
"description": "The witness server securely intermediates internet data exchange, using TLS and zero-knowledge proofs to verify and sign user claims with minimal information disclosure.",
55
"main": "lib/index",
66
"scripts": {
77
"build": "tsc -p tsconfig.build.json && tsc-alias",
@@ -75,7 +75,7 @@
7575
"https-proxy-agent": "^7.0.5",
7676
"jsdom": "^24.1.3",
7777
"jsonpath-plus": "^10.0.0",
78-
"p-queue": "^8.0.1",
78+
"p-queue": "^6.6.2",
7979
"pino": "^9.4.0",
8080
"protobufjs": "^7.4.0",
8181
"re2": "^1.21.4",

provider-schemas/http/parameters.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ properties:
9898
description: >-
9999
Inverses the matching logic.
100100
Fail when match is found and proceed otherwise
101+
hash:
102+
type: boolean
103+
description: >-
104+
If true, the response will be hashed and the hash will be used
105+
in the witness
101106
additionalProperties: false
102107
responseRedactions:
103108
type: array

src/providers/http/index.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { utils } from 'ethers'
12
import { concatenateUint8Arrays, strToUint8Array, TLSConnectionOptions } from '@reclaimprotocol/tls'
23
import { base64 } from 'ethers/lib/utils'
34
import { DEFAULT_HTTPS_PORT, RECLAIM_USER_AGENT } from 'src/config'
@@ -382,7 +383,7 @@ const HTTP_PROVIDER: Provider<'http'> = {
382383
}
383384

384385

385-
for(const { type, value, invert } of params.responseMatches || []) {
386+
for(const { type, value, invert, hash } of params.responseMatches || []) {
386387
const inv = Boolean(invert) // explicitly cast to boolean
387388

388389
switch (type) {
@@ -406,7 +407,13 @@ const HTTP_PROVIDER: Provider<'http'> = {
406407
throw new Error(`Duplicate parameter ${paramName}`)
407408
}
408409

409-
extractedParams[paramName] = groups[paramName]
410+
if(hash) {
411+
extractedParams[paramName] = utils.keccak256(
412+
strToUint8Array(groups[paramName])
413+
).toLowerCase()
414+
} else {
415+
extractedParams[paramName] = groups[paramName]
416+
}
410417
}
411418

412419
break

src/types/providers.gen.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export interface HttpProviderParameters {
5555
* Inverses the matching logic. Fail when match is found and proceed otherwise
5656
*/
5757
invert?: boolean;
58+
/**
59+
* If true, the response will be hashed and the hash will be used
60+
* in the witness
61+
*/
62+
hash?: boolean;
5863
}[];
5964
/**
6065
* which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. "HTTP/1.1 200 OK") * To disable any redactions, pass an empty array
@@ -81,7 +86,7 @@ export interface HttpProviderParameters {
8186
};
8287
}
8388

84-
export const HttpProviderParametersJson = {"title":"HttpProviderParameters","type":"object","required":["url","method","responseMatches"],"properties":{"url":{"type":"string","format":"url","description":"which URL does the request have to be made to Has to be a valid https URL for eg. https://amazon.in/orders?q=abcd"},"method":{"type":"string","enum":["GET","POST","PUT","PATCH"]},"geoLocation":{"type":"string","nullable":true,"pattern":"^[A-Za-z]{0,2}$","description":"Specify the geographical location from where to proxy the request. 2-letter ISO country code"},"headers":{"type":"object","description":"Any additional headers to be sent with the request Note: these will be revealed to the attestor & won't be redacted from the transcript. To add hidden headers, use 'secretParams.headers' instead","additionalProperties":{"type":"string"}},"body":{"description":"Body of the HTTP request","oneOf":[{"type":"string","format":"binary"},{"type":"string"}]},"writeRedactionMode":{"type":"string","description":"If the API doesn't perform well with the \"key-update\" method of redaction, you can switch to \"zk\" mode by setting this to \"zk\"","enum":["zk","key-update"]},"additionalClientOptions":{"type":"object","description":"Apply TLS configuration when creating the tunnel to the attestor.","nullable":true,"properties":{"supportedProtocolVersions":{"type":"array","minItems":1,"uniqueItems":true,"items":{"type":"string","enum":["TLS1_2","TLS1_3"]}}}},"responseMatches":{"type":"array","minItems":1,"uniqueItems":true,"description":"The attestor will use this list to check that the redacted response does indeed match all the provided strings/regexes","items":{"type":"object","required":["value","type"],"properties":{"value":{"type":"string","description":"\"regex\": the response must match the regex \"contains\": the response must contain the provided\n string exactly"},"type":{"type":"string","description":"The string/regex to match against","enum":["regex","contains"]},"invert":{"type":"boolean","description":"Inverses the matching logic. Fail when match is found and proceed otherwise"}},"additionalProperties":false}},"responseRedactions":{"type":"array","uniqueItems":true,"description":"which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the attestor. The attestor will only be able to see the selected portions alongside the first line of the HTTP response (i.e. \"HTTP/1.1 200 OK\") * To disable any redactions, pass an empty array","items":{"type":"object","properties":{"xPath":{"type":"string","nullable":true,"description":"expect an HTML response, and to contain a certain xpath for eg. \"/html/body/div.a1/div.a2/span.a5\""},"jsonPath":{"type":"string","nullable":true,"description":"expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'"},"regex":{"type":"string","nullable":true,"description":"select a regex match from the response"}},"additionalProperties":false}},"paramValues":{"type":"object","description":"A map of parameter values which are user in form of {{param}} in URL, responseMatches, responseRedactions, body, geolocation. Those in URL, responseMatches & geo will be put into context and signed This value will NOT be included in provider hash","additionalProperties":{"type":"string"}}},"additionalProperties":false}
89+
export const HttpProviderParametersJson = {"title":"HttpProviderParameters","type":"object","required":["url","method","responseMatches"],"properties":{"url":{"type":"string","format":"url","description":"which URL does the request have to be made to Has to be a valid https URL for eg. https://amazon.in/orders?q=abcd"},"method":{"type":"string","enum":["GET","POST","PUT","PATCH"]},"geoLocation":{"type":"string","nullable":true,"pattern":"^[A-Za-z]{0,2}$","description":"Specify the geographical location from where to proxy the request. 2-letter ISO country code"},"headers":{"type":"object","description":"Any additional headers to be sent with the request Note: these will be revealed to the witness & won't be redacted from the transcript. To add hidden headers, use 'secretParams.headers' instead","additionalProperties":{"type":"string"}},"body":{"description":"Body of the HTTP request","oneOf":[{"type":"string","format":"binary"},{"type":"string"}]},"writeRedactionMode":{"type":"string","description":"If the API doesn't perform well with the \"key-update\" method of redaction, you can switch to \"zk\" mode by setting this to \"zk\"","enum":["zk","key-update"]},"additionalClientOptions":{"type":"object","description":"Apply TLS configuration when creating the tunnel to the witness.","nullable":true,"properties":{"supportedProtocolVersions":{"type":"array","minItems":1,"uniqueItems":true,"items":{"type":"string","enum":["TLS1_2","TLS1_3"]}}}},"responseMatches":{"type":"array","minItems":1,"uniqueItems":true,"description":"The witness will use this list to check that the redacted response does indeed match all the provided strings/regexes","items":{"type":"object","required":["value","type"],"properties":{"value":{"type":"string","description":"\"regex\": the response must match the regex \"contains\": the response must contain the provided\n string exactly"},"type":{"type":"string","description":"The string/regex to match against","enum":["regex","contains"]},"invert":{"type":"boolean","description":"Inverses the matching logic. Fail when match is found and proceed otherwise"},"hash":{"type":"boolean","description":"Hashes the value"}},"additionalProperties":false}},"responseRedactions":{"type":"array","uniqueItems":true,"description":"which portions to select from a response. These are selected in order, xpath => jsonPath => regex * These redactions are done client side and only the selected portions are sent to the witness. The witness will only be able to see the selected portions alongside the first line of the HTTP response (i.e. \"HTTP/1.1 200 OK\") * To disable any redactions, pass an empty array","items":{"type":"object","properties":{"xPath":{"type":"string","nullable":true,"description":"expect an HTML response, and to contain a certain xpath for eg. \"/html/body/div.a1/div.a2/span.a5\""},"jsonPath":{"type":"string","nullable":true,"description":"expect a JSON response, retrieve the item at this path using dot notation for e.g. 'email.addresses.0'"},"regex":{"type":"string","nullable":true,"description":"select a regex match from the response"}},"additionalProperties":false}},"paramValues":{"type":"object","description":"A map of parameter values which are user in form of {{param}} in URL, responseMatches, responseRedactions, body, geolocation. Those in URL, responseMatches & geo will be put into context and signed This value will NOT be included in provider hash","additionalProperties":{"type":"string"}}},"additionalProperties":false}
8590
/**
8691
* Secret parameters to be used with HTTP provider. None of the values in this object will be shown to the attestor
8792
*/

src/utils/zk.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { detectEnvironment, getEnvVariable } from 'src/utils/env'
2020
import { getPureCiphertext, getRecordIV, getZkAlgorithmForCipherSuite } from 'src/utils/generics'
2121
import { logger as LOGGER } from 'src/utils/logger'
2222
import { isFullyRedacted, isRedactionCongruent, REDACTION_CHAR_CODE } from 'src/utils/redactions'
23+
import PQueue = require('p-queue');
2324

2425
type GenerateZKChunkProofOpts = {
2526
key: Uint8Array
@@ -80,8 +81,7 @@ export async function makeZkProofGenerator(
8081
}: PrepareZKProofsOpts
8182
) {
8283

83-
const { default: PQueue } = await import('p-queue')
84-
const zkQueue = new PQueue({
84+
const zkQueue = new PQueue.default({
8585
concurrency: zkProofConcurrency,
8686
autoStart: true,
8787
})

0 commit comments

Comments
 (0)