mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
Objective-C
55 lines
1.3 KiB
Objective-C
//
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "SendingChain.h"
|
|
#import "ChainKey.h"
|
|
#import <SignalCoreKit/OWSAsserts.h>
|
|
|
|
@interface SendingChain ()
|
|
|
|
@property (nonatomic)ChainKey *chainKey;
|
|
|
|
@end
|
|
|
|
@implementation SendingChain
|
|
|
|
static NSString* const kCoderChainKey = @"kCoderChainKey";
|
|
static NSString* const kCoderSenderRatchet = @"kCoderSenderRatchet";
|
|
|
|
+ (BOOL)supportsSecureCoding{
|
|
return YES;
|
|
}
|
|
|
|
- (id)initWithCoder:(NSCoder *)aDecoder{
|
|
self = [self initWithChainKey:[aDecoder decodeObjectOfClass:[ChainKey class] forKey:kCoderChainKey]
|
|
senderRatchetKeyPair:[aDecoder decodeObjectOfClass:[ECKeyPair class] forKey:kCoderSenderRatchet]];
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)encodeWithCoder:(NSCoder *)aCoder{
|
|
[aCoder encodeObject:self.chainKey forKey:kCoderChainKey];
|
|
[aCoder encodeObject:self.senderRatchetKeyPair forKey:kCoderSenderRatchet];
|
|
}
|
|
|
|
- (instancetype)initWithChainKey:(ChainKey *)chainKey senderRatchetKeyPair:(ECKeyPair *)keyPair{
|
|
self = [super init];
|
|
|
|
OWSAssert(chainKey.key.length == 32);
|
|
OWSAssert(keyPair);
|
|
|
|
if (self) {
|
|
_chainKey = chainKey;
|
|
_senderRatchetKeyPair = keyPair;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
-(ChainKey *)chainKey{
|
|
return _chainKey;
|
|
}
|
|
|
|
@end
|