Remove unnecessary mut in PodSigner trait (#340)

The PodSigner trait was taking `&mut self` in the `sign` method, but the
signer doesn't need mutation in the Shcnorr implementation.  Remove the
`mut`.

Previously the PodProver trait was also taking `&mut self` in the
`prove` method, and we had many tests creating a `mut Prover/mut
MockProver`.  Remove all those `mut`.

Breaking change: `PodSigner` trait method `sign` replaces `&mut self` by
`&self`
This commit is contained in:
Eduard S. 2025-07-15 17:37:26 +02:00 committed by GitHub
parent b5e0d97cb6
commit 63a716ebd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 136 additions and 146 deletions

View file

@ -46,14 +46,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let game_sk = SecretKey::new_rand();
let game_pk = game_sk.public_key();
let mut game_signer = Signer(game_sk);
let game_signer = Signer(game_sk);
// Build 2 signed pods where the game assigns points to a player that has completed a level.
let mut builder = SignedPodBuilder::new(&params);
builder.insert("player", "Alice");
builder.insert("level", 1);
builder.insert("points", 3512);
let pod_points_lvl_1 = builder.sign(&mut game_signer)?;
let pod_points_lvl_1 = builder.sign(&game_signer)?;
pod_points_lvl_1.verify()?;
println!("# pod_points_lvl_1:\n{}", pod_points_lvl_1);
@ -61,7 +61,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
builder.insert("player", "Alice");
builder.insert("level", 2);
builder.insert("points", 5771);
let pod_points_lvl_2 = builder.sign(&mut game_signer)?;
let pod_points_lvl_2 = builder.sign(&game_signer)?;
pod_points_lvl_2.verify()?;
println!("# pod_points_lvl_2:\n{}", pod_points_lvl_2);

View file

@ -17,7 +17,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let pk = sk.public_key();
println!("Public key: {}\n", pk);
let mut signer = Signer(sk);
let signer = Signer(sk);
// Build the signed pod
let mut builder = SignedPodBuilder::new(&params);
@ -35,7 +35,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
);
// Sign the pod and verify it
let pod = builder.sign(&mut signer)?;
let pod = builder.sign(&signer)?;
pod.verify()?;
println!("{}", pod);