-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dict-manager' of github.com:lambdaclass/cairo-rs-py int…
…o squash-dict-add-test-tags
- Loading branch information
Showing
13 changed files
with
277 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
%builtins output pedersen ecdsa | ||
|
||
from starkware.cairo.common.cairo_builtins import HashBuiltin, SignatureBuiltin | ||
from starkware.cairo.common.hash import hash2 | ||
from starkware.cairo.common.signature import verify_ecdsa_signature | ||
|
||
func main{output_ptr : felt*, pedersen_ptr : HashBuiltin*, ecdsa_ptr : SignatureBuiltin*}(): | ||
alloc_locals | ||
|
||
let your_eth_addr = 874739451078007766457464989774322083649278607533249481151382481072868806602 | ||
let signature_r = 1839793652349538280924927302501143912227271479439798783640887258675143576352 | ||
let signature_s = 1819432147005223164874083361865404672584671743718628757598322238853218813979 | ||
let msg = 0000000000000000000000000000000000000000000000000000000000000002 | ||
|
||
verify_ecdsa_signature( | ||
msg, | ||
your_eth_addr, | ||
signature_r, | ||
signature_s, | ||
) | ||
|
||
|
||
assert [output_ptr] = your_eth_addr | ||
let output_ptr = output_ptr + 1 | ||
|
||
return () | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::collections::HashMap; | ||
|
||
use cairo_rs::{ | ||
types::relocatable::Relocatable, | ||
vm::{errors::vm_errors::VirtualMachineError, runners::builtin_runner::SignatureBuiltinRunner}, | ||
}; | ||
|
||
use num_bigint::BigInt; | ||
use pyo3::prelude::*; | ||
|
||
use crate::relocatable::PyRelocatable; | ||
|
||
#[pyclass(name = "Signature")] | ||
#[derive(Clone, Debug)] | ||
pub struct PySignature { | ||
signatures: HashMap<PyRelocatable, (BigInt, BigInt)>, | ||
} | ||
|
||
#[pymethods] | ||
impl PySignature { | ||
#[new] | ||
pub fn new() -> Self { | ||
Self { | ||
signatures: HashMap::new(), | ||
} | ||
} | ||
|
||
pub fn add_signature(&mut self, address: PyRelocatable, pair: (BigInt, BigInt)) { | ||
self.signatures.insert(address, pair); | ||
} | ||
} | ||
|
||
impl PySignature { | ||
pub fn update_signature( | ||
&self, | ||
signature_builtin: &mut SignatureBuiltinRunner, | ||
) -> Result<(), VirtualMachineError> { | ||
for (address, pair) in self.signatures.iter() { | ||
signature_builtin | ||
.add_signature(Relocatable::from(address), pair) | ||
.map_err(VirtualMachineError::MemoryError)? | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl Default for PySignature { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl ToPyObject for PySignature { | ||
fn to_object(&self, py: Python<'_>) -> PyObject { | ||
self.clone().into_py(py) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.