it.auties.whatsapp.model.signal.sender.SenderChainKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of whatsappweb4j Show documentation
Show all versions of whatsappweb4j Show documentation
Standalone fully-featured Whatsapp Web API for Java and Kotlin
package it.auties.whatsapp.model.signal.sender;
import it.auties.whatsapp.crypto.Hmac;
import lombok.Builder;
import lombok.extern.jackson.Jacksonized;
@Builder
@Jacksonized
public record SenderChainKey(int iteration, byte[] seed) {
private static final byte[] MESSAGE_KEY_SEED = {0x01};
private static final byte[] CHAIN_KEY_SEED = {0x02};
public SenderMessageKey toMessageKey() {
var hmac = Hmac.calculateSha256(MESSAGE_KEY_SEED, seed);
return new SenderMessageKey(iteration, hmac);
}
public SenderChainKey next() {
var hmac = Hmac.calculateSha256(CHAIN_KEY_SEED, seed);
return new SenderChainKey(iteration + 1, hmac);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy