signalapp / libsignal

Home to the Signal Protocol as well as other cryptographic primitives which make Signal possible.
GNU Affero General Public License v3.0
3.63k stars 420 forks source link

Add unidentified access key derivation method #508

Closed rubdos closed 1 year ago

rubdos commented 1 year ago

We've been implementing our own access key derivation function for a while now in libsignal-service, currently as an extention trait, but it feels a bit weird not to have it in here.

Things up for discussion:

This is a suggestion PR, so feel free to suggest alternative approaches :)

rubdos commented 1 year ago

For the known-answer tests, I've generated a few using our own pre-existing (and working) implementation, but feel free to add some of your own to make sure.

Generated using:

use libsignal_service::push_service::ProfileKeyExt;
use rand::Rng;
use zkgroup::profiles::ProfileKey;

fn main() {
    let profile_key = ProfileKey::generate(rand::thread_rng().gen());
    let access_key = profile_key.derive_access_key();
    println!("({:#x?}, {access_key:#x?})", profile_key.get_bytes());
}
jrose-signal commented 1 year ago

Pulled into v0.23.0. Thank you!