pub fn ciphertext_from_miracl(ciphertext: &crypto::Crsz) -> FsEncryptionCiphertext {
    let rand_r = {
        assert_eq!(
            ciphertext.rr.len(),
            NUM_CHUNKS,
            "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext"
        );
        let mut rand_r = [G1Bytes([0u8; G1Bytes::SIZE]); NUM_CHUNKS];
        for (dst, src) in rand_r[..].iter_mut().zip(&ciphertext.rr) {
            *dst = miracl_g1_to_bytes(src);
        }
        rand_r
    };
    let rand_s = {
        assert_eq!(
            ciphertext.ss.len(),
            NUM_CHUNKS,
            "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext"
        );
        let mut rand_s = [G1Bytes([0u8; G1Bytes::SIZE]); NUM_CHUNKS];
        for (dst, src) in rand_s[..].iter_mut().zip(&ciphertext.ss) {
            *dst = miracl_g1_to_bytes(src);
        }
        rand_s
    };
    let rand_z = {
        assert_eq!(
            ciphertext.zz.len(),
            NUM_CHUNKS,
            "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext"
        );
        let mut rand_z = [G2Bytes([0u8; G2Bytes::SIZE]); NUM_CHUNKS];
        for (dst, src) in rand_z[..].iter_mut().zip(&ciphertext.zz) {
            *dst = miracl_g2_to_bytes(src);
        }
        rand_z
    };
    let ciphertext_chunks = ciphertext.cc.iter().map(|cj| {
            assert_eq!(cj.len(), NUM_CHUNKS, "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext");
            let mut cc = [G1Bytes([0u8;G1Bytes::SIZE]);NUM_CHUNKS];
            for (dst, src) in cc[..].iter_mut().zip(cj){ *dst = miracl_g1_to_bytes(src); }
            cc
        }).collect();

    FsEncryptionCiphertext {
        rand_r,
        rand_s,
        rand_z,
        ciphertext_chunks,
    }
}
/// Serialises a ciphertext from the miracl representation into the standard
/// form.
///
/// # Panics
/// This will panic if the miracl representation is invalid.  Given that the
/// miracl representation is generated internally, this can happen only if there
/// is an error in our code.
Serialises a ciphertext from the miracl representation into the standard
form.
Serialises a ciphertext from the miracl representation into the standard form .
pub fn ciphertext_from_miracl(ciphertext: &crypto::Crsz) -> FsEncryptionCiphertext {
    let rand_r = {
        assert_eq!(
            ciphertext.rr.len(),
            NUM_CHUNKS,
            "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext"
        );
        let mut rand_r = [G1Bytes([0u8; G1Bytes::SIZE]); NUM_CHUNKS];
        for (dst, src) in rand_r[..].iter_mut().zip(&ciphertext.rr) {
            *dst = miracl_g1_to_bytes(src);
        }
        rand_r
    };
    let rand_s = {
        assert_eq!(
            ciphertext.ss.len(),
            NUM_CHUNKS,
            "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext"
        );
        let mut rand_s = [G1Bytes([0u8; G1Bytes::SIZE]); NUM_CHUNKS];
        for (dst, src) in rand_s[..].iter_mut().zip(&ciphertext.ss) {
            *dst = miracl_g1_to_bytes(src);
        }
        rand_s
    };
    let rand_z = {
        assert_eq!(
            ciphertext.zz.len(),
            NUM_CHUNKS,
            "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext"
        );
        let mut rand_z = [G2Bytes([0u8; G2Bytes::SIZE]); NUM_CHUNKS];
        for (dst, src) in rand_z[..].iter_mut().zip(&ciphertext.zz) {
            *dst = miracl_g2_to_bytes(src);
        }
        rand_z
    };
    let ciphertext_chunks = ciphertext.cc.iter().map(|cj| {
            assert_eq!(cj.len(), NUM_CHUNKS, "Incorrect number of chunks from Miracl-library formatted forward secure Ciphertext");
            let mut cc = [G1Bytes([0u8;G1Bytes::SIZE]);NUM_CHUNKS];
            for (dst, src) in cc[..].iter_mut().zip(cj){ *dst = miracl_g1_to_bytes(src); }
            cc
        }).collect();
    FsEncryptionCiphertext {
        rand_r,
        rand_s,
        rand_z,
        ciphertext_chunks,
    }
}
pub fn ciphertext_from_miracl ( ciphertext : & crypto :: Crsz ) -> FsEncryptionCiphertext { let rand_r = { assert_eq ! ( ciphertext rr len ( ) NUM_CHUNKS " " ) ; let mut rand_r = [ G1Bytes ( [ 0u8 ; G1Bytes :: SIZE ] ) ; NUM_CHUNKS ] ; for ( dst , src ) in rand_r [ .. ] . iter_mut ( ) . zip ( & ciphertext . rr ) { * dst = miracl_g1_to_bytes ( src ) ; } rand_r } ; let rand_s = { assert_eq ! ( ciphertext ss len ( ) NUM_CHUNKS " " ) ; let mut rand_s = [ G1Bytes ( [ 0u8 ; G1Bytes :: SIZE ] ) ; NUM_CHUNKS ] ; for ( dst , src ) in rand_s [ .. ] . iter_mut ( ) . zip ( & ciphertext . ss ) { * dst = miracl_g1_to_bytes ( src ) ; } rand_s } ; let rand_z = { assert_eq ! ( ciphertext zz len ( ) NUM_CHUNKS " " ) ; let mut rand_z = [ G2Bytes ( [ 0u8 ; G2Bytes :: SIZE ] ) ; NUM_CHUNKS ] ; for ( dst , src ) in rand_z [ .. ] . iter_mut ( ) . zip ( & ciphertext . zz ) { * dst = miracl_g2_to_bytes ( src ) ; } rand_z } ; let ciphertext_chunks = ciphertext . cc . iter ( ) . map ( | cj | { assert_eq ! ( cj len ( ) NUM_CHUNKS " " ) ; let mut cc = [ G1Bytes ( [ 0u8 ; G1Bytes :: SIZE ] ) ; NUM_CHUNKS ] ; for ( dst , src ) in cc [ .. ] . iter_mut ( ) . zip ( cj ) { * dst = miracl_g1_to_bytes ( src ) ; } cc } ) . collect ( ) ; FsEncryptionCiphertext { rand_r , rand_s , rand_z , ciphertext_chunks , } }
Serialises a ciphertext from the miracl representation into the standard
form.
Serialises a ciphertext from the miracl representation into the standard form .
ciphertext
&crypto::Crsz
ciphertext
&crypto::Crsz
panics
This will panic if the miracl representation is invalid.  Given that the
miracl representation is generated internally, this can happen only if there
is an error in our code.
This will panic if the miracl representation is invalid . Given that the miracl representation is generated internally this can happen only if there is an error in our code .