-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for webrtc and certhash (#261) #262
Merged
achingbrain
merged 7 commits into
multiformats:master
from
little-bear-labs:jt/261-webrtc
Aug 30, 2022
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5ea7b52
fix: Add support for webrtc and certhash (#261)
John-LittleBearLabs f351942
Added a test for certhash encoding.
John-LittleBearLabs cab5d25
Updated to reduce size of dependency.
John-LittleBearLabs 178b660
Revert "Updated to reduce size of dependency."
John-LittleBearLabs 344e8f8
Supporting the others, removed custom proto-specific codecs.
John-LittleBearLabs 33e5b30
Back to base64url as the default base for ToString
John-LittleBearLabs 561bf9b
Updated for PR comments.
John-LittleBearLabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,4 +87,18 @@ describe('convert', () => { | |
expect(convert.convertToString('sctp', buffer.subarray(5))).to.equal('1234') | ||
}) | ||
}) | ||
|
||
it('can round-trip certhash, though encoding base may change', ()=>{ | ||
let myCertFingerprint = { | ||
"algorithm": "sha-256", | ||
"value": "f4:32:a0:45:34:62:85:e0:d8:d7:75:36:84:72:8e:b2:aa:9e:71:64:e4:eb:fe:06:51:64:42:64:fe:04:a8:d0" | ||
}; | ||
let mb = 'f' + myCertFingerprint.value.replaceAll(':',''); | ||
let bytes = convert.convertToBytes('certhash',mb); | ||
let outcome = convert.convertToString(466, bytes); | ||
//Although I sent hex encoding in, base58btc always comes out | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment valid? Looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. The comment is out-of-date. |
||
expect(outcome).to.equal('u9DKgRTRiheDY13U2hHKOsqqecWTk6_4GUWRCZP4EqNA'); | ||
let bytesOut = convert.convertToBytes(466,outcome); | ||
expect(bytesOut.toString()).to.equal(bytes.toString()); | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any verification required that the decoded multibase contains a valid multihash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's an easy way to verify that. The existing multihash function does one validation I did not replicate here,
https://github.com/multiformats/js-multiaddr/blob/master/src/convert.ts#L158-L160
That it reports a size that is correct. I could (maybe should) do that. But to go beyond that I think we'd have to be aware of all the supported encryption schemes, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achingbrain - thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, otherwise as you say it would have to know about all the available hash algorithms.