MCPcopy Create free account
hub / github.com/docknetwork/crypto / get_resp_for_message

Method get_resp_for_message

proof_system/src/verifier.rs:1914–1939  ·  view source on GitHub ↗

Get the response for a witness from the tracked responses of witness equalities. Expects the response to exist else throws error. This is not to be called for signature proof protocols but others whose responses are expected to come from them or pedersen commitment protocols.

(
        statement_idx: usize,
        witness_idx: usize,
        disjoint_equalities: &[EqualWitnesses],
        resp_for_equalities: &BTreeMap<usize, E::ScalarField>,
    )

Source from the content-addressed store, hash-verified

1912 /// Expects the response to exist else throws error. This is not to be called for signature proof protocols
1913 /// but others whose responses are expected to come from them or pedersen commitment protocols.
1914 fn get_resp_for_message(
1915 statement_idx: usize,
1916 witness_idx: usize,
1917 disjoint_equalities: &[EqualWitnesses],
1918 resp_for_equalities: &BTreeMap<usize, E::ScalarField>,
1919 ) -> Result<E::ScalarField, ProofSystemError> {
1920 let wit_ref = (statement_idx, witness_idx);
1921 let mut resp = None;
1922 for (i, eq) in disjoint_equalities.iter().enumerate() {
1923 if eq.has_wit_ref(&wit_ref) {
1924 if let Some(r) = resp_for_equalities.get(&i) {
1925 resp = Some(*r);
1926 } else {
1927 return Err(ProofSystemError::NoResponseFoundForWitnessRef(
1928 statement_idx,
1929 witness_idx,
1930 ));
1931 }
1932 // Exit loop because equalities are disjoint
1933 break;
1934 }
1935 }
1936 resp.ok_or_else(|| {
1937 ProofSystemError::NoResponseFoundForWitnessRef(statement_idx, witness_idx)
1938 })
1939 }
1940}

Callers

nothing calls this directly

Calls 3

has_wit_refMethod · 0.80
getMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected