<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mark McCaskey on Medium]]></title>
        <description><![CDATA[Stories by Mark McCaskey on Medium]]></description>
        <link>https://medium.com/@mark_66398?source=rss-ebe5b895a47c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*RwkRHTofD-malgkM8PbDAg.png</url>
            <title>Stories by Mark McCaskey on Medium</title>
            <link>https://medium.com/@mark_66398?source=rss-ebe5b895a47c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:14:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mark_66398/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rust 2020: Rust at Wasmer]]></title>
            <link>https://blog.wasmer.io/rust-2020-rust-at-wasmer-7646646a2024?source=rss-ebe5b895a47c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7646646a2024</guid>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Mark McCaskey]]></dc:creator>
            <pubDate>Fri, 29 Nov 2019 21:31:18 GMT</pubDate>
            <atom:updated>2019-11-29T21:31:18.784Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AIPDT5nQEal_i4YkV8HiqA.png" /></figure><p>This article is a response to the <a href="https://blog.rust-lang.org/2019/10/29/A-call-for-blogs-2020.html">call for blog posts about Rust in 2020</a> and beyond. We’ll overview how Rust development in 2019 has impacted <a href="https://wasmer.io/">us as a small company</a> using a lot of advanced Rust features for our <a href="https://github.com/wasmerio/wasmer">WebAssembly runtime</a> and <a href="https://github.com/wasmerio/wapm-cli/">tools</a>, what we’re thankful for in Rust this year, the problems we face, and what we would like to see in the future.</p><h3>👍 The good</h3><p>We love Rust at Wasmer! In fact, we were a <a href="https://rustconf.com/sponsors/">diamond sponsor at this year’s RustConf</a> because Rust is such a key part of what we do and we think it’s extremely important for companies to give back to the Free and Open Source software projects that they rely on.</p><p>The Rust language over the past year has made some incredible improvements that have had a very real impact on the quality of what we’ve been able to create. Rust 2018 has been a significant improvement in language simplicity and intuitiveness.</p><p>Here are some of the new features we appreciate the most.</p><h4>Non-lexical-lifetimes</h4><p>This significantly improved ergonomics and allowed for better error messages. The inline reborrowing removes the need to use a lot of extra levels of nesting.</p><p>For example, if we wanted to feed a dog we used to have to explicitly tell Rust (through lexical scope) that we were done with the dog’s mouth after feeding and that we were done with the dog’s biographical information after looking at it before we could compliment the dog:</p><pre>{<br>    let mouth = dog.get_mouth_mut();<br>    if mouth.is_hungry() {<br>        mouth.give_food();<br>    }<br>} // drop mutable borrow to mouth<br>let message = {<br>    let info = dog.get_info();<br>    format!(&quot;{}, you&#39;re a good {}!&quot;, info.name, info.gender)<br>}; // drop immutable borrow to info<br>tell_dog(&amp;mut dog, message);</pre><p>But with NLL, we can now more directly interact with our furry friends:</p><pre>let mouth = dog.get_mouth_mut();<br>if mouth.is_hungry() {<br>    mouth.give_food();<br>}<br>let info = dog.get_info(); // automatically drops mutable borrow<br>let message = format!(&quot;{}, you&#39;re a good {}!&quot;, info.name, info.gender);<br>tell_dog(&amp;mut dog, message); // automatically drops immutable borrow</pre><p>The end result that is that it’s much quicker to write Rust and have things “just work”.</p><h4>The dbg! macro</h4><p>The dbg!macro allows for inline inspection of intermediate values. It works on any expression that has a result which is Debug. It’s a very small detail, but a real quality of life improvement.</p><p>For example if we have an expression that’s long but makes sense as a single expression, like:</p><pre>let x_plus = -1 * b + sqrt(b * b + 4 * a * c) / (2 * a);</pre><p>But our intermediate values aren’t as we expect and we want to quickly inspect them then we used to have to make significant structural edits that we’d have to undo before we could ship the code.</p><pre>let b_square = b * b;<br>let four_ac = 4 * a * c;<br>let sqrt_result = sqrt(b_squared + four_ac);<br>let rhs = sqrt_result / 2 * a;<br>let final_result = -1 * b + sqrt_result;<br>println!(&quot;b * b = {}; 4 * a * c = {}; sqrt(b * b + 4 * a * ) = {}; sqrt(b * b + 4 * a * c) / (2 * a) = {}; -1 * b + sqrt(b * b + 4 * a * c) / (2 * a) = {}&quot;, b_square, four_ac, sqrt_result, rhs, final_result);</pre><p>And this is strictly worse because it doesn’t include file and line information and the text describing what the values are doesn’t stay in sync with the actual code that’s computing them.</p><p>However now we can do:</p><pre>let x_plus = dbg!(-1 * b + dbg!(sqrt(dbg!(b * b) + dbg!(4 * a * c)) / (2 * a)));</pre><p>Which is way cleaner, easier to use, easier to delete, and easier to detect as development-only debug code. It was always possible to implement something like dbg! and then use it from an external crate, but having something like this always available — even in throw-away example code — is a game changer for quickly iterating on Rust code and I miss it every time I use a language that’s not Rust.</p><h4>Various stdlib improvements</h4><p>Some of the biggest for us this year are the stabilization of to/from_*e_bytes, Pin, TryFrom, and atomic integers as well as the addition of new features like MaybeUninit. We won’t go into the details here, but they let us be more precise about what we want and make getting things done easier.</p><h4>Cargo quality of life features</h4><p>Cargo is extremely nice. When it works, it does exactly what you’d expect and gets out of your way — and it usually works great! We’ll highlight two new features of Cargo that we’re especially thankful for this year:</p><p>The --offline flag allows cargo to operate well with dependencies even without an internet connection. This doesn’t come up often for us, but we’re extremely glad it exists when we do need it.</p><p>The default-run field. This allows multiple binary targets in a Cargo workspace without forcing the user to specify which one should run when using cargo run. This is a small detail, but it’s had a big impact for us. It’s easy to forget that your project has other binary targets, especially if they’re small utilities that we don’t normally interact with but are important to have. When working on projects like that, I often forget to specify the target which results in a consistent loss of at least 1–10 seconds every time it happens due to having to reorient to the error if I’ve changed tabs to do something else and having to edit the previously run command. Small paper-cuts like these can multiply together and ruin my focus causing my productivity to plummet.</p><p>The Rust language and ecosystem’s attention to detail for things like this really make Rust a pleasure to use.</p><h3>👎 The “bad” — What can be improved?</h3><p>There weren’t any changes in 2019 or in the 2018 edition that were bad for us, there are only things that haven’t been improved as much as we would have liked yet:</p><h4>Some error messages with lifetimes</h4><p>We ran into some lifetime issues recently when upgrading a dependency. In an <em>extremely</em> long function, stable Rust was not pointing to the cause of issue making it nearly unresolvable. Fortunately, by using the nightly compiler and #![feature(nll)] we were able to get the specific and detailed error messages that we’re used to from Rust.</p><h4>Lack of <a href="https://github.com/rust-lang/cargo/issues/2980">mutually exclusive features</a> in Cargo</h4><p>This is a surprisingly pervasive issue — it affects us both directly and indirectly. It would really make things easier if there were two types of features: standard features and mutually exclusive features/sets of features.</p><p>The most common use case we have is something that an enum would solve very cleanly: there are multiple options but it only makes sense to use one and exactly one of them.</p><p>However looking at it generally, it would be nice to encode more of the information about how features can and cannot be used in the Cargo manifest directly, instead of in cfg logic that enables and disables calls to compiler_error!.</p><h3>What we want to see going forward</h3><p>Our team is made up of people with very different amounts of Rust experience so we’re able to offer the perspectives of a new user from a web-development background, a new user from a C++ background, and a user since the beta with a functional programming background:</p><h4>Rust from the perspective of a web developer</h4><p>Cargo and <a href="http://crates.io/">crates.io</a> are an amazing resource. I find it’s extremely helpful for new developers to have a way to hit the ground running building cool things, and a great package ecosystem can definitely encourage that. I also feel like crates on <a href="http://crates.io/">crates.io</a> will be an amazing resource for Rust and WebAssembly, for building complex Wasm modules by utilizing or porting existing crates.</p><p>However, Rust source code is really hard to read. The amount of syntax and special characters can make lines feel cluttered and the language can seem overwhelming. Additionally, because Rust is positioned as a language to use for WebAssembly, many web developers may be trying it out without a background in systems programming. The distinction between things like arrays, vectors, and boxes is confusing. Therefore, Rust could focus on making the language easier to use for developers from these backgrounds.</p><h4>Rust from the perspective of a C++ developer</h4><p>People often say that Rust is like C++, but it’s more like OCaml than it is like C++. I really like the Rust ecosystem: cargo and crates.io are fantastic. And Rust has some great features like pattern matching.</p><p>Due to the nature of the work we do (generating machine code and running it) we have to use a lot of unsafe. Rust doesn’t just need a better understanding of the possible effects of unsafe, it needs better runtime tools for debugging it. Aside from the obvious cases where we need unsafe, we run into more issues than it seems like we should where we need unsafe just to do what we want.</p><p>The Send + Sync traits work for guaranteeing thread safety, but in the context of executing WebAssembly it can be restrictive. For example, we don’t know if the module we’re compiling will have shared memory statically or not and the solutions are either pay runtime costs or solve the problem with unsafe.</p><p>Another issue is that Rust can’t easily map well to patterns used in C++ and specifically used in LLVM. When attempting to implement mixins in <a href="https://github.com/TheDan64/inkwell">Inkwell</a>, due to some of the overlap in functionality between the traits, we weren’t able to implement this in Rust in a sensible way. The way that this works in C++ is by using multiple inheritance. Another feature that would be nice to have is an unsafe way to catch or at least throw an exception from Rust for FFI purposes.</p><h4>Rust from the perspective of a Rust and FP developer</h4><p>Rust has improved so much during my time using it. The way the language has been developing is extremely exciting and it’s impossible for me to pick just one thing I’d like Rust to focus on, so I’ll limit myself to talking about a few things here and talk about how they would help improve Rust:</p><ul><li>Standard map!, and set! macros that act like vec!. This would be like a generic version of the macros in the <a href="https://crates.io/crates/maplit">maplit</a> crate, but in the stdlib. I’m a big fan of the small stdlib that Rust has, but for day to day programming these core data structures are so important (a fact proven by their inclusion in the stdlib) that being able to concisely and ergonomically construct them will encourage a more obviously correct, readable, and composable style.</li><li>Deeper abstractions. The biggest feature I miss from Haskell are the core traits that define so little, yet by which extremely powerful and abstract things are built. For example, I wish I could write functions that return impl <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/Control-Monad-Fail.html#t:MonadFail">MonadFail</a> and have the caller decide how they want to receive their errors: as an Option, as a Result, as an empty data structure, or as anything else a user may want for their own types. These types of abstractions improve code reuse, ergonomics, and productivity.</li><li>Safer unsafe. For almost the entire time I’ve used Rust, I essentially never <em>needed</em> to use unsafe. However since joining Wasmer, I’ve written a lot of unsafe code. When dealing with the complexities of FFI, existing libraries, and when trying to expose a safe, sound API over a large system that does some fundamentally unsafe things, it’s very hard to be confident that everything is correct. I don’t know exactly what the solution to this is, but it would be nice if there were levels of unsafe or tools for auditing the safety of unsafe code.</li></ul><p>Rust strikes a good balance between being easy to use and safe/expressive and it’s important that we preserve that. In general, I think Rust is doing a fantastic job overall but there’s always more to improve. One last thing I hope to see in 2020 is… myself contributing to Rust more seriously!</p><h3>Wrapping it up</h3><p>Rust 2018 was a success for us and we’re looking forward to seeing how Rust develops going forward. Knowing that the language and ecosystem is constantly improving gives us confidence that no matter how hard the technical challenges we face are, Rust is growing with us and will help us get things done.</p><p>Thank you to the Rust teams and all the contributors for your hard work this year!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7646646a2024" width="1" height="1" alt=""><hr><p><a href="https://blog.wasmer.io/rust-2020-rust-at-wasmer-7646646a2024">Rust 2020: Rust at Wasmer</a> was originally published in <a href="https://blog.wasmer.io/">Wasmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing WAPM Packages with Package Signing]]></title>
            <link>https://blog.wasmer.io/securing-wapm-packages-with-package-signing-3cf0d12f32f3?source=rss-ebe5b895a47c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cf0d12f32f3</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[package-management]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Mark McCaskey]]></dc:creator>
            <pubDate>Tue, 25 Jun 2019 17:44:38 GMT</pubDate>
            <atom:updated>2019-06-25T17:44:38.210Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/wasmerio/wapm-cli/">WAPM</a> is a new package manager from <a href="https://github.com/wasmerio/wasmer">Wasmer</a> designed to make packaging and distributing WebAssembly simple and easy.</p><p>We released wapm <a href="https://medium.com/wasmer/announcing-wapm-the-webassembly-package-manager-18d52fae0eea">about two months ago</a> and have been iterating from all the feedback that we’ve received. In response we quickly released version <a href="https://github.com/wasmerio/wapm-cli/blob/master/CHANGELOG.md#020---2019-05-06">0.2.0</a> with many usability improvements and some <a href="https://medium.com/wasmer/introducing-wapm-global-package-installs-2efa3e834e4">new functionality too</a>.</p><p>Following up on that, we began development of a package signing system as part of 0.3.0 and 0.3.1, which we will dive into the details of here.</p><h3>What is Package Signing?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fXjiC6QbkxVQZqQESMrzQ.png" /></figure><p>Package signing is a way for the author of the package to allow users of their package to verify that it really came from the author and that it<strong> hasn’t been tampered with</strong>.</p><blockquote>It’s like the modern version of using <a href="https://en.wikipedia.org/wiki/Sealing_wax">sealing wax</a> with a <a href="https://en.wikipedia.org/wiki/Seal_(emblem)#Signet_rings">difficult to replicate imprint</a> to verify the authenticity and integrity of the letter.</blockquote><p>Package signing is a <em>critical ingredient</em> in a Package Manager. Here are a few reasons why:</p><ul><li><strong>Prevention of tampering</strong>: without package signing, the owner of the package repository, or anyone who may have gained illegitimate access, can make undetectable, malicious changes to packages.</li><li><strong>Verification of identity</strong>: the maintainer can publish proofs through other trusted channels such as: their own website, Keybase, social media, or in person. This allows users to know the origin of the package.</li><li><strong>Verification of continuity</strong>: even if the package maintainer’s account is compromised, the signing key will remain secret, thus updates signed with the same key can be trusted and updates that are not signed with that key will not be implicitly trusted.</li></ul><p>Our implementation uses <a href="https://jedisct1.github.io/minisign/">Minisign</a> (which uses <a href="https://ed25519.cr.yp.to/">Ed25519</a>) for the public-private key pairs used for package signing. In the future wapm may support various types of cryptography for verification for users with additional needs, but Minisign has <a href="https://ed25519.cr.yp.to/">many desirable properties</a> that make it a fantastic default choice.</p><p>Our trust system is a simple <a href="https://en.wikipedia.org/wiki/Trust_on_first_use">TOFU</a> (Trust On First Use) scheme where the package-consuming user is prompted to verify public keys from the package-producing user, if they haven’t seen the key before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*I59sa46AAAOs3C2gM2_3Vw.png" /><figcaption>High level control flow of TOFU</figcaption></figure><p>Currently all new keys must be validated by the package-consuming user manually. The next improvement to our TOFU system will be to add support for key revocation and chains of trust (using a trusted key to sign a new key).</p><p>In addition to our TOFU system, users may import trusted public keys manually with wapm keys import. Through this and future APIs, we may support more sophisticated trust schemes than TOFU.</p><h3>How to Sign a Package</h3><p>Here’s what setting up and using it as a package maintainer looks like:</p><pre># Create keys directory inside wasmer<br>mkdir -p ~/.wasmer/keys/</pre><pre># Generate and register a key pair<br>wapm keys generate ~/.wasmer/keys/</pre><p>Which can be done manually by generating a key with the <a href="https://wapm.io/package/jedisct1/rsign2">wapm package rsign2</a> (or any <a href="https://github.com/jedisct1/minisign">Minisign implementation</a>) and registering it with wapm.</p><pre># Install rsign to generate keys<br>wapm install -g <a href="https://wapm.io/package/jedisct1/rsign2">jedisct1/rsign2</a></pre><pre># Generate the key pair<br>wapm run rsign --dir=. -- generate</pre><pre># Register the keys with wapm<br>wapm keys register --public rsign.pub --private .rsign/rsign.key</pre><p>Once the keys are created and registered, we can publish the package as usual:</p><pre>wapm publish</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4_kA82tRmkHlghrSstTN6A.png" /><figcaption>Signed Packages will show a green check icon next to the <a href="https://wapm.io/package/jedisct1/minisign">package name</a></figcaption></figure><h4>Installing a Signed Package</h4><p>From the package consumer’s perspective, this is what we will see once we try to install a signed package:</p><pre># Install a signed package<br>$ <strong>wapm install user/package</strong></pre><pre>[INFO] Installing user/package@0.0.4</pre><pre>New public key encountered: 3F6D278A36843FFE RWT+P4Q2iidtP7bkcLP4fBTYc9YPpuTKNVIquvPPnsFXrGdecaMKpQ+t while installing package@0.0.4.<br><strong>Would you like to trust this key?<br></strong>[y/n] y</pre><pre>[INFO] Importing key &quot;3F6D278A36843FFE&quot; for user &quot;user&quot;<br>[INFO] Signature of package package@0.0.4 verified!<br>Package installed successfully to wapm_packages!</pre><p>Additionally, there are key management commands to handle anything else related to package signing. See the <a href="https://wapm.io/help/reference">wapm reference</a> for more information.</p><h3>Going forward</h3><p>Please try it out and let us know what you think! To get started just update your version of wasmer with wasmer self-update and you’ll get the latest version of wapm too! Or, if you’re new to wasmer, visit the <a href="https://wasmer.io/">website</a> for installation instructions.</p><p>We will continue to improve the key signing story by adding support for key rotation by supporting chains of trust and key revocation.<br>Aside from package signing, we plan to work with the community to <a href="https://github.com/wasmerio/wapm-cli/issues/115">continue to improve security</a>.</p><p>If you’re interested in working on wapm or <a href="https://wasmer.io/">Wasmer</a>, we’re available to mentor and assist as needed! Looking to get even more involved? We’re hiring!</p><blockquote>Big thanks to <a href="https://github.com/jedisct1/">Frank Denis</a> for creating <a href="https://wapm.io/package/jedisct1/minisign">Minisign</a>, answering all our questions, providing feedback, and being generally awesome!<br>Additional thanks to <a href="https://github.com/frehberg">Frank Rehberger</a> for the valuable suggestions and feedback!<br>Our work wouldn’t be possible without your help ❤️</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cf0d12f32f3" width="1" height="1" alt=""><hr><p><a href="https://blog.wasmer.io/securing-wapm-packages-with-package-signing-3cf0d12f32f3">Securing WAPM Packages with Package Signing</a> was originally published in <a href="https://blog.wasmer.io/">Wasmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>