Crypto_core_hsalsa20 with Swift

I use ‘TweetNacl’ ( for this step:
“Both sides derive a long term shared secret key s from k using function kdf1”
And I use SL public key and CL secret key from example 1.

I get three different values. But all of them iare wrong.

Could anybody explain how it do right?

There are only for params: result buffer (64 bytes), random number from 64 to 128, SL and CL keys.

My code

func method1(mySecretKey:Data, theirPublicKey:Data) {
    var bytes = UnsafeMutablePointer(mutating: [UInt8](Data(count: 64)))
    let secretCodePointer = UnsafePointer([UInt8](mySecretKey))
    let theirPublicKeyPointer = UnsafePointer([UInt8](theirPublicKey))

    crypto_stream_salsa20_tweet(bytes, 64, secretCodePointer, theirPublicKeyPointer)
    print("\(Data(bytes:bytes, count: 64))")

No direct answer to your question, but maybe one of this two Nuki Fob implementations are of help for you:

Unfortunately, no one from these answers doesn’t allow me to know how can I achieve right result with kdf1 function.