@Override public boolean removeMetadataBlob( UserPublicKey owner, byte[] encodedWritingPublicKey, byte[] writingKeySignedMapKeyPlusBlob) { UserPublicKey writingKey = new UserPublicKey(encodedWritingPublicKey); try { byte[] payload = writingKey.unsignMessage(writingKeySignedMapKeyPlusBlob); byte[] mapKey = Arrays.copyOfRange(payload, 0, 32); byte[] metadataBlob = Arrays.copyOfRange( payload, 32, payload .length); // will be zero length for now // TODO change to the current blob hash MetadataBlob blob = new MetadataBlob(writingKey.getPublicKeys(), mapKey, metadataBlob); return blob.delete(); } catch (TweetNaCl.InvalidSignatureException e) { System.err.println( "Invalid signature during removeMetadataBlob for owner: " + owner + " and sharer: " + writingKey); return false; } }
@Override public boolean removeFollowRequest(UserPublicKey owner, byte[] req) { try { byte[] unsigned = owner.unsignMessage(req); FollowRequestData request = new FollowRequestData(owner, unsigned); return request.delete(); } catch (TweetNaCl.InvalidSignatureException e) { return false; } }
@Override public boolean setStaticData(UserPublicKey owner, byte[] signedStaticData) { try { StaticData userData = new StaticData(owner.getPublicKeys(), owner.unsignMessage(signedStaticData)); return userData.insert(); } catch (TweetNaCl.InvalidSignatureException e) { System.err.println("Invalid signature setting static data for: " + owner); return false; } }
@Override public boolean setMetadataBlob( UserPublicKey owner, byte[] encodedWritingPublicKey, byte[] writingKeySignedMapKey) { UserPublicKey writingKey = new UserPublicKey(encodedWritingPublicKey); try { byte[] payload = writingKey.unsignMessage(writingKeySignedMapKey); byte[] mapKey = Arrays.copyOfRange(payload, 0, 32); byte[] metadataBlob = Arrays.copyOfRange(payload, 32, payload.length); MetadataBlob blob = new MetadataBlob(writingKey.getPublicKeys(), mapKey, metadataBlob); return blob.insert(); } catch (TweetNaCl.InvalidSignatureException e) { System.err.println( "Invalid signature during setMetadataBlob for owner: " + owner + " and sharer: " + writingKey); return false; } }