Skip to content

Commit fda3406

Browse files
Replace sha256 with sha512
1 parent a7102ec commit fda3406

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/ecc/circuit/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ openvm-algebra-circuit = { workspace = true }
2020
openvm-rv32-adapters = { workspace = true }
2121
openvm-ecc-transpiler = { workspace = true }
2222
openvm-ecc-guest = { workspace = true, features = ["ed25519"] }
23-
openvm-sha256-circuit = { workspace = true }
23+
openvm-sha2-circuit = { workspace = true }
2424

2525
num-bigint = { workspace = true }
2626
num-integer = { workspace = true }

extensions/ecc/circuit/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use openvm_algebra_circuit::*;
22
use openvm_circuit::arch::{InitFileGenerator, SystemConfig};
33
use openvm_circuit_derive::VmConfig;
44
use openvm_rv32im_circuit::*;
5-
use openvm_sha256_circuit::{Sha256, Sha256Executor, Sha256Periphery};
5+
use openvm_sha2_circuit::{Sha2, Sha2Executor, Sha2Periphery};
66
use openvm_stark_backend::p3_field::PrimeField32;
77
use serde::{Deserialize, Serialize};
88

@@ -23,7 +23,7 @@ pub struct Rv32EccConfig {
2323
#[extension]
2424
pub ecc: EccExtension,
2525
#[extension]
26-
pub sha256: Sha256,
26+
pub sha2: Sha2,
2727
}
2828

2929
impl Rv32EccConfig {
@@ -47,7 +47,7 @@ impl Rv32EccConfig {
4747
io: Default::default(),
4848
modular: ModularExtension::new(primes),
4949
ecc: EccExtension::new(sw_curves, te_curves),
50-
sha256: Default::default(),
50+
sha2: Default::default(),
5151
}
5252
}
5353
}

extensions/ecc/guest/src/eddsa.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use openvm_algebra_guest::{IntMod, Reduce};
2-
use openvm_sha2::sha256;
2+
use openvm_sha2::sha512;
33

44
use crate::{edwards::TwistedEdwardsPoint, CyclicGroup, FromCompressed, IntrinsicCurve};
55

@@ -38,8 +38,7 @@ where
3838
return false;
3939
};
4040

41-
// TODO: replace with sha512
42-
let prehash = sha256(message);
41+
let prehash = sha512(message);
4342

4443
// h = SHA512(dom2(F, C) || R || A || PH(M))
4544
// RFC reference: https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.7
@@ -61,8 +60,7 @@ where
6160
sha_input.extend_from_slice(&encode_point::<C>(&self.point));
6261
sha_input.extend_from_slice(&prehash);
6362

64-
// TOOD: replace with sha512
65-
let h = sha256(&sha_input);
63+
let h = sha512(&sha_input);
6664

6765
let h = C::Scalar::reduce_le_bytes(&h);
6866

extensions/ecc/tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ openvm-stark-sdk.workspace = true
1212
openvm-circuit = { workspace = true, features = ["test-utils"] }
1313
openvm-transpiler.workspace = true
1414
openvm-algebra-transpiler.workspace = true
15-
openvm-sha256-transpiler.workspace = true
15+
openvm-sha2-transpiler.workspace = true
1616
openvm-ecc-transpiler.workspace = true
1717
openvm-ecc-circuit.workspace = true
1818
openvm-rv32im-transpiler.workspace = true

extensions/ecc/tests/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod tests {
2626
config::{AppConfig, SdkVmConfig},
2727
StdIn,
2828
};
29-
use openvm_sha256_transpiler::Sha256TranspilerExtension;
29+
use openvm_sha2_transpiler::Sha2TranspilerExtension;
3030
use openvm_stark_backend::p3_field::FieldAlgebra;
3131
use openvm_stark_sdk::{openvm_stark_backend, p3_baby_bear::BabyBear};
3232
use openvm_toolchain_tests::{
@@ -336,7 +336,7 @@ mod tests {
336336
.with_extension(Rv32IoTranspilerExtension)
337337
.with_extension(EccTranspilerExtension)
338338
.with_extension(ModularTranspilerExtension)
339-
.with_extension(Sha256TranspilerExtension),
339+
.with_extension(Sha2TranspilerExtension),
340340
)?;
341341
air_test(config, openvm_exe);
342342
Ok(())

0 commit comments

Comments
 (0)