remove file lost in merge

This commit is contained in:
Alex Stokes 2018-12-12 21:58:21 -08:00
parent e339d4bd71
commit 9b59acb95b
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086

View File

@ -1,67 +0,0 @@
use super::hashing::canonical_hash;
use super::ssz::SszStream;
use super::types::Hash256;
/// Generates the message used to validate the signature provided with an AttestationRecord.
///
/// Ensures that the signer of the message has a view of the chain that is compatible with ours.
pub fn generate_signed_message(
slot: u64,
parent_hashes: &[Hash256],
shard_id: u16,
shard_block_hash: &Hash256,
justified_slot: u64,
) -> Vec<u8> {
/*
* Note: it's a little risky here to use SSZ, because the encoding is not necessarily SSZ
* (for example, SSZ might change whilst this doesn't).
*
* I have suggested switching this to ssz here:
* https://github.com/ethereum/eth2.0-specs/issues/5
*
* If this doesn't happen, it would be safer to not use SSZ at all.
*/
let mut ssz_stream = SszStream::new();
ssz_stream.append(&slot);
ssz_stream.append_vec(&parent_hashes.to_vec());
ssz_stream.append(&shard_id);
ssz_stream.append(shard_block_hash);
ssz_stream.append(&justified_slot);
let bytes = ssz_stream.drain();
canonical_hash(&bytes)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_generate_signed_message() {
let slot = 93;
let parent_hashes: Vec<Hash256> = (0..12).map(|i| Hash256::from(i as u64)).collect();
let shard_id = 15;
let shard_block_hash = Hash256::from("shard_block_hash".as_bytes());
let justified_slot = 18;
let output = generate_signed_message(
slot,
&parent_hashes,
shard_id,
&shard_block_hash,
justified_slot,
);
/*
* Note: this is not some well-known test vector, it's simply the result of running
* this and printing the output.
*
* Once well-known test vectors are established, they should be placed here.
*/
let expected = vec![
185, 80, 24, 37, 184, 189, 129, 206, 109, 64, 116, 30, 221, 36, 160, 48, 114, 87, 138,
139, 79, 57, 83, 39, 122, 42, 214, 135, 95, 204, 235, 161,
];
assert_eq!(output, expected);
}
}