Skip to content

Commit 52b0f29

Browse files
committed
refactor: use randomness for trusted setup
1 parent 693f8db commit 52b0f29

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.github/actions/setup/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ runs:
108108
shell: bash
109109
run: npm install -g @lightprotocol/zk-compression-cli
110110

111+
- name: Cache Powers of Tau file
112+
if: inputs.install-circom == 'true'
113+
uses: actions/cache@v4
114+
with:
115+
path: ${{ inputs.example }}/pot/powersOfTau28_hez_final_16.ptau
116+
key: ptau-powersOfTau28_hez_final_16-v1
117+
111118
- name: Cache circom installation
112119
if: inputs.install-circom == 'true'
113120
id: cache-circom

zk-id/scripts/setup.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ fi
169169
# Contribute to the ceremony
170170
echo ""
171171
echo "Contributing to the ceremony..."
172+
# Generate real randomness from /dev/urandom combined with system entropy
173+
# This creates 256 bits of entropy for the contribution
174+
RANDOM_ENTROPY=$(head -c 32 /dev/urandom | xxd -p -c 256)
175+
SYSTEM_ENTROPY="${RANDOM}${RANDOM}${RANDOM}$(date +%s%N)$(uname -a | sha256sum | cut -d' ' -f1)"
176+
COMBINED_ENTROPY="${RANDOM_ENTROPY}${SYSTEM_ENTROPY}"
177+
172178
npx snarkjs zkey contribute \
173179
build/circuit_0000.zkey \
174180
build/compressed_account_merkle_proof_final.zkey \
175181
--name="First contribution" \
176182
-v \
177-
-e="$(date +%s)"
183+
-e="$COMBINED_ENTROPY"
178184

179185
if [ $? -eq 0 ]; then
180186
echo -e "${GREEN}${NC} Contribution complete"

0 commit comments

Comments
 (0)