mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
* refactor project structure * environment-based default registry * fix tests * update build container * use docker platform for iso build emulation * simplify compat * Fix docker platform spec in run-compat.sh * handle riscv compat * fix bug with dep error exists attr * undo removal of sorting * use qemu for iso stage --------- Co-authored-by: Mariusz Kogen <k0gen@pm.me> Co-authored-by: Matt Hill <mattnine@protonmail.com>
35 lines
933 B
Rust
35 lines
933 B
Rust
use ed25519_dalek::{Signature, SigningKey, VerifyingKey};
|
|
use sha2::Sha512;
|
|
|
|
use crate::prelude::*;
|
|
use crate::sign::SignatureScheme;
|
|
|
|
pub struct Ed25519;
|
|
impl SignatureScheme for Ed25519 {
|
|
type SigningKey = SigningKey;
|
|
type VerifyingKey = VerifyingKey;
|
|
type Signature = Signature;
|
|
type Digest = Sha512;
|
|
fn new_digest(&self) -> Self::Digest {
|
|
<Self::Digest as digest::Digest>::new()
|
|
}
|
|
fn sign(
|
|
&self,
|
|
key: &Self::SigningKey,
|
|
digest: Self::Digest,
|
|
context: &str,
|
|
) -> Result<Self::Signature, Error> {
|
|
Ok(key.sign_prehashed(digest, Some(context.as_bytes()))?)
|
|
}
|
|
fn verify(
|
|
&self,
|
|
key: &Self::VerifyingKey,
|
|
digest: Self::Digest,
|
|
context: &str,
|
|
signature: &Self::Signature,
|
|
) -> Result<(), Error> {
|
|
key.verify_prehashed_strict(digest, Some(context.as_bytes()), signature)?;
|
|
Ok(())
|
|
}
|
|
}
|