Skip to content

Commit

Permalink
rid of verifier registry address env var (#59)
Browse files Browse the repository at this point in the history
* rid of verifier registry address env var

* rotate in prog

* rotation

* -

* fixtest
  • Loading branch information
shaharyakir authored Mar 12, 2024
1 parent a99bb61 commit ef0d74d
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 21 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
SOURCES_REGISTRY=EQD-BJSVUJviud_Qv7Ymfd3qzXdrmV525e3YDzWQoHIAiInL
VERIFIER_REGISTRY=EQDS0AW7NV1w3nFwx-mmryfpH4OGQ3PXnoFGOJA_8PTHuLrw
VERIFIER_ID=orbs.com

This comment has been minimized.

Copy link
@Hiwotgetachew

Hiwotgetachew Sep 22, 2024

💥Id: 5958676948

IPFS_PROVIDER=tonsource.infura-ipfs.io
COMPILE_TIMEOUT=5000
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ To deploy on heroku, you can use the [func compilation buildpack](https://github
- `PRIVATE_KEY` - To sign its message cell with a private key, which is verified by the [verifier registry](https://github.com/ton-blockchain/TEPs/pull/91). Provide an ED25519 compatible private key.
- `SOURCES_REGISTRY` - The address of the sources registry contract (default from .env)
- `VERIFIER_ID` - Sources verifier id (default from .env)
- `VERIFIER_REGISTRY` - The address of the verifier registry contract (default from .env)

## Running

Expand Down
12 changes: 3 additions & 9 deletions script/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#!/bin/bash
set -e

if [ ! -f ".secret" ]; then
echo >&2 "Error: .secret does not exist."
exit 1
fi
source .secret

if [[ $1 == "testnet" ]]; then
values=("prod-testnet-1")
echo "Deploying to tesnet only!"
values=("prod-testnet-1")
echo "Deploying to tesnet only!"
else
values=("prod-testnet-1" "prod-1" "prod-2" "prod-3")
values=("prod-testnet-1" "prod-1" "prod-2" "prod-3")
fi

for heroku_app in "${values[@]}"; do
Expand Down
8 changes: 8 additions & 0 deletions script/generate-private-key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const nacl = require("tweetnacl");

const keypair = nacl.sign.keyPair();
const privKey = Buffer.from(keypair.secretKey).toString("base64");
const pubKey = Buffer.from(keypair.publicKey).toString("base64");

console.log(`Private key: ${privKey}`);
console.log(`Public key: ${pubKey}`);
1 change: 0 additions & 1 deletion src/check-prerequisites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getFuncVersions } from "./fetch-func-versions";
export async function checkPrerequisites() {
const missingEnvVars = [
"VERIFIER_ID",
"VERIFIER_REGISTRY",
"SOURCES_REGISTRY",
"INFURA_ID",
"INFURA_SECRET",
Expand Down
4 changes: 2 additions & 2 deletions src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface ControllerConfig {
privateKey: string;
sourcesRegistryAddress: string;
allowReverification: boolean;
verifierRegistryAddress: string;
}

export class Controller {
Expand All @@ -53,6 +52,7 @@ export class Controller {
this.keypair = tweetnacl.sign.keyPair.fromSecretKey(
Buffer.from(this.config.privateKey, "base64"),
);

this.tonReaderClient = tonReaderClient;
}

Expand Down Expand Up @@ -142,7 +142,7 @@ export class Controller {

const verifierConfig = await this.tonReaderClient.getVerifierConfig(
this.config.verifierId,
this.config.verifierRegistryAddress,
this.config.sourcesRegistryAddress,
);

const { ipfsPointer, codeCellHash, senderAddress, queryId } = validateMessageCell(
Expand Down
1 change: 0 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ app.get("/hc", (req, res) => {
allowReverification: !!process.env.ALLOW_REVERIFICATION,
privateKey: process.env.PRIVATE_KEY!,
sourcesRegistryAddress: process.env.SOURCES_REGISTRY!,
verifierRegistryAddress: process.env.VERIFIER_REGISTRY!,
},
new TonReaderClientImpl(),
);
Expand Down
17 changes: 12 additions & 5 deletions src/ton-reader-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { sha256 } from "./utils";
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { ContractVerifier } from "@ton-community/contract-verifier-sdk";
import { VerifierRegistry } from "./wrappers/verifier-registry";
import { SourcesRegistry } from "./wrappers/sources-registry";

export type VerifierConfig = {
verifiers: Buffer[];
Expand All @@ -13,7 +14,6 @@ export type VerifierConfig = {

export interface TonReaderClient {
isProofDeployed(codeCellHash: string, verifierId: string): Promise<boolean | undefined>;

getVerifierConfig(verifierId: string, verifierRegistryAddress: string): Promise<VerifierConfig>;
}

Expand All @@ -39,13 +39,20 @@ export function createNullValue(): DictionaryValue<null> {
export class TonReaderClientImpl implements TonReaderClient {
async getVerifierConfig(
verifierId: string,
verifierRegistryAddress: string,
sourcesRegistryAddress: string,
): Promise<VerifierConfig> {
const tc = await getTonClient();
const verifierRegstryContract = tc.open(
VerifierRegistry.createFromAddress(Address.parse(verifierRegistryAddress)),

const sourcesRegistryContract = tc.open(
SourcesRegistry.createFromAddress(Address.parse(sourcesRegistryAddress)),
);
const res = await verifierRegstryContract.getVerifier(toBigIntBE(sha256(verifierId)));

const verifierRegistryAddress = await sourcesRegistryContract.getVerifierRegistryAddress();
const verifierRegistryContract = tc.open(
VerifierRegistry.createFromAddress(verifierRegistryAddress),
);

const res = await verifierRegistryContract.getVerifier(toBigIntBE(sha256(verifierId)));
const verifierConfig = res.settings!.beginParse();

const quorum = verifierConfig.loadUint(8);
Expand Down
1 change: 0 additions & 1 deletion test/controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ function makeController(keypair: tweetnacl.SignKeyPair): Controller {
allowReverification: false,
sourcesRegistryAddress: randomAddress("sourcesReg").toString(),
verifierId: VERIFIER_ID,
verifierRegistryAddress: randomAddress("verifierReg").toString(),
},
stubTonReaderClient,
);
Expand Down

0 comments on commit ef0d74d

Please sign in to comment.