mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-06 20:41:11 +00:00
Cleanup verification variable declarations.
This commit is contained in:
parent
3840cb9733
commit
2e5363c679
1 changed files with 21 additions and 11 deletions
|
|
@ -809,16 +809,21 @@ impl PublicKey {
|
||||||
pub fn verify<D>(&self, message: &[u8], signature: &Signature) -> Result<(), SignatureError>
|
pub fn verify<D>(&self, message: &[u8], signature: &Signature) -> Result<(), SignatureError>
|
||||||
where D: Digest<OutputSize = U64> + Default
|
where D: Digest<OutputSize = U64> + Default
|
||||||
{
|
{
|
||||||
let A = self.0.decompress()
|
let mut h: D = D::default();
|
||||||
.ok_or_else(|| SignatureError(InternalError::PointDecompressionError))?;
|
let R: EdwardsPoint;
|
||||||
|
let k: Scalar;
|
||||||
|
|
||||||
|
let A: EdwardsPoint = match self.0.decompress() {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err => Err(SignatureError(InternalError::PointDecompressionError))),
|
||||||
|
};
|
||||||
|
|
||||||
let mut h = D::default();
|
|
||||||
h.input(signature.r.as_bytes());
|
h.input(signature.r.as_bytes());
|
||||||
h.input(self.as_bytes());
|
h.input(self.as_bytes());
|
||||||
h.input(&message);
|
h.input(&message);
|
||||||
let k = Scalar::from_hash(h);
|
|
||||||
|
|
||||||
let R = EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(-A), &signature.s);
|
k = Scalar::from_hash(h);
|
||||||
|
R = EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(-A), &signature.s);
|
||||||
|
|
||||||
if R.compress() == signature.r {
|
if R.compress() == signature.r {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -852,13 +857,18 @@ impl PublicKey {
|
||||||
signature: &Signature) -> Result<(), SignatureError>
|
signature: &Signature) -> Result<(), SignatureError>
|
||||||
where D: Digest<OutputSize = U64> + Default
|
where D: Digest<OutputSize = U64> + Default
|
||||||
{
|
{
|
||||||
let ctx = context.unwrap_or(b"");
|
let mut h: D = D::default();
|
||||||
|
let R: EdwardsPoint;
|
||||||
|
let k: Scalar;
|
||||||
|
|
||||||
|
let ctx: &[u8] = context.unwrap_or(b"");
|
||||||
debug_assert!(ctx.len() <= 255, "The context must not be longer than 255 octets.");
|
debug_assert!(ctx.len() <= 255, "The context must not be longer than 255 octets.");
|
||||||
|
|
||||||
let A = self.0.decompress()
|
let A: EdwardsPoint = match self.0.decompress() {
|
||||||
.ok_or_else(|| SignatureError(InternalError::PointDecompressionError))?;
|
Ok(x) => x,
|
||||||
|
Err => Err(SignatureError(InternalError::PointDecompressionError))),
|
||||||
|
};
|
||||||
|
|
||||||
let mut h = D::default();
|
|
||||||
h.input(b"SigEd25519 no Ed25519 collisions");
|
h.input(b"SigEd25519 no Ed25519 collisions");
|
||||||
h.input(&[1]); // Ed25519ph
|
h.input(&[1]); // Ed25519ph
|
||||||
h.input(&[ctx.len() as u8]);
|
h.input(&[ctx.len() as u8]);
|
||||||
|
|
@ -866,9 +876,9 @@ impl PublicKey {
|
||||||
h.input(signature.r.as_bytes());
|
h.input(signature.r.as_bytes());
|
||||||
h.input(self.as_bytes());
|
h.input(self.as_bytes());
|
||||||
h.input(prehashed_message.fixed_result().as_slice());
|
h.input(prehashed_message.fixed_result().as_slice());
|
||||||
let k = Scalar::from_hash(h);
|
|
||||||
|
|
||||||
let R = EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(-A), &signature.s);
|
k = Scalar::from_hash(h);
|
||||||
|
R = EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(-A), &signature.s);
|
||||||
|
|
||||||
if R.compress() == signature.r {
|
if R.compress() == signature.r {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue